JQuery 动画中 stop() 和 Delay() 的问题
正如您在 http://jsfiddle.net/FrelCee/5zcv3/4/ 上看到的,我想在容器悬停时为这 3 个 div 制作动画。
问题是当您多次快速悬停时会出现这个丑陋的队列。 我还尝试使用 .stop() 函数,但 delay() 不起作用。
这是一个 stop() 函数和 delay() 问题的示例: http://jsfiddle.net/FrelCee /FHC99/22/
有谁知道更好的方法吗?
提前致谢!
As you can see on http://jsfiddle.net/FrelCee/5zcv3/4/ , i want to animate those 3 divs when the container is hovered.
Problem is this ugly queue that appears when you fast hover more than once.
I also tried using .stop() function, but then the delay() isn't working.
Here is an example with stop() function and delay() problem : http://jsfiddle.net/FrelCee/FHC99/22/
Does anyone know any better way to this?
Thanks in advance!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您只需要至少向
.stop(true, true)
提供第一个参数即可清除当前队列,并且您可以决定是否还想提供第二个参数以跳转到队列的末尾下一个开始时的动画(这取决于您,因为它会产生稍微不同的效果)。您还需要将.stop()
调用放在.delay()
之前,这样就不会清除.delay()
。请参阅 jQuery.stop()
文档以了解这两个参数.stop()
。当我在这里这样做时: http://jsfiddle.net/jfriend00/pYgQr/ ,似乎处理快速悬停进/出就好了。另外,我不知道你为什么一开始就这样做:
你可以这样做:
或者这样:
此外,没有理由这样做:
这些id在页面中必须是唯一的,所以最好use:
这在 jQuery 中会更快,因为它将能够在内部使用
document.getElementById('first')
。You just need to supply at least the first parameter to
.stop(true, true)
to clear the current queue and you can decide if you also want to supply the second parameter to jump to the end of the animation when the next one starts (that's up to you as it gives a slightly different effect). You also need to place the.stop()
calls before the.delay()
so you aren't clearing the.delay()
. See the jQuery doc for.stop()
to understand the two parameters for.stop()
. When I do that here: http://jsfiddle.net/jfriend00/pYgQr/, it seems to handle fast hover in/out just fine.Also, I don't know why you're doing this at the beginning:
You can either do this:
or this:
In addition, there is no reason to do:
These are ids which must be unique in the page so it's better to use:
This will be faster in jQuery because it will be able to just use
document.getElementById('first')
internally.试试这个 http://jsfiddle.net/5zcv3/5/
你不必同时使用两者
delay
和animate
,只需给animate
不同的速度即可; 效果类似,stop
是必须的根据我的经验,
try this http://jsfiddle.net/5zcv3/5/
you don't have to use both
delay
andanimate
, just giveanimate
different speed; the effect is similarbased on my experience,
stop
is a must