jQuery暂停/恢复动画

这对我不起作用……

$(document).ready(function(){ $('#h .a').animate({ top:'-=80px' },90,'linear'); $('#h .au,#h .di').animate({ left:'-=80px' },50000000,'linear'); $('#h .r').animate({ left:'-=80px' },250,'linear'); $("#h").animate('pause'); //pausing it at the start //resume pause switch $("#h").mouseover(function(){ $(this).animate('resume'); }).mouseout(function(){ $(this).animate('pause'); }); }); 

在这里查看演示: http : //api.jquery.com/clearQueue/

看起来就像你正在尝试做的那样。

尝试这个暂停和恢复: jQuery暂停/恢复动画插件

我们$(this).stop()可以暂停动画,但没有机会恢复!

其他错误就是这个: top:'-=80px'

首先尝试获得这样的当前位置然后添加位置:

 _top = $(this).offset().top; $('#h .a').animate({ top:_top-80 },90,'linear') 

使用queue()和dequeue()函数。 这是一个直接从jQuery文档中获取的示例。

查看http://jsfiddle.net/j4SNS/上的工作示例

检查插件:Fxqueues

https://github.com/lucianopanaro/jQuery-FxQueues

它支持暂停和恢复(不清除队列)并添加了Scopes的想法。 范围非常适合跨多个对象链接动画。

我还没有找到当前版本的Jquery的Fxqueus版本,但是已经成功地使用了旧的Jquery版本。

您将需要考虑使用.stop()函数,因为它将停止jQuery元素上的任何动画。

http://api.jquery.com/stop/