jQuery的停止()似乎会阻止那些没有被排队尚未动画 [英] jQuery's stop() seems to be blocking animations that haven't been queued yet

查看:203
本文介绍了jQuery的停止()似乎会阻止那些没有被排队尚未动画的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何jQuery的停止()实际工作?

How does jQuery's stop() actually work?

如果你看看这里(http://jsfiddle.net/hWTT6/),当你将鼠标悬停在主要的蓝盒子应该褪色的红色,而当你关闭悬停它应该渐退。现在的问题是它会完全褪色的红色(然后再返回到蓝),即使鼠标一直徘徊断第一褪色完成之前。这个问题可以更清楚地与滑动效果看出。将鼠标悬停在幻灯片按钮,主框将滑动到蓝色,徘徊过,它会向后滑动。但尝试徘徊和关闭和开启和关闭,第一个动画完成之前。你会看到,所有四个动画进行。我包括这两个例子这里显示它不只是一个效果什么的问题。

If you look here (http://jsfiddle.net/hWTT6/), when you hover over the main blue box it should fade to red, and when you hover off it should fade back. The problem is it will completely fade to red (and then back to blue) even if the mouse has hovered off before the first fade was complete. The problem can more clearly be seen with the slide effect. Hover over the slide "button" and the main box will slide to blue, hover off, it will slide back. But try hovering on and off and on and off, before the first animation has completed. You'll see that all four animations are carried out. I included both examples here to show it is not just a problem with one effect or something.

我认为这将通过增加很容易地固定在动画之前停止,如code中所示注释掉。但是,如果我这样做了当前动画将停止和下一个将不会开始。几乎就像停止被阻止的的调用后发生的动画停止

I thought this would be easily fixed by adding a stop before the animations, as shown commented out in the code. But, if I do this the current animation will stop and the following one will never start. Almost as though stop is blocking an animation that is occurring after the call to stop.

我是什么在这里失踪?

感谢。

推荐答案

您是缺少 .stop()接受两个参数。无论布尔值,说明:

You are missing that .stop() accepts two arguments. Both boolean, indicating:

- clearQueue (first)
- jumpToEnd (second)

所以,通过调用 $('#富')。停止(真的,真).doSomeOtherStuff()你应该得到你想要的目标。

So by calling $('#foo').stop( true, true ).doSomeOtherStuff() you should get your desired goal.

参考: .stop()

这篇关于jQuery的停止()似乎会阻止那些没有被排队尚未动画的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆