jQuery 停止动画
我有一个带有 jQuery 动画的菜单栏。上面有一个滑动图像效果。当您将鼠标悬停在每个项目上时,图像会发生变化,当您将鼠标悬停在整个菜单栏之外时,图像会更改为默认菜单栏。
问题:但是,如果您在当前活动的动画完成之前将鼠标悬停在整个菜单栏之外,它不会更改为上述默认图像,并且您将卡在另一个图像上,直到您再次缓慢地将鼠标移出。这种情况经常发生,并导致动画的方向全部混乱。
当我将鼠标移出整个菜单时,我需要一种方法来使用 jQuery 来停止中间的所有其他动画。因此,每当鼠标离开整个区域时,请取消所有动画,然后将动画恢复为默认值。
我的 JS 文件已缩小,但您可以在这里查看: http://designsweeter.com/live/bcmedical/wp -content/themes/designsweeter/scripts/menu.js
美化的JS: http://designsweeter.com/live/bcmedical/prettymenu.js
I have a menubar with a jQuery animations. There's a sliding image effect on it. When you hover over it each item, the image changes, when you hover out of the entire menubar hen it changes to a default menubar.
The problem: However, if you hover out of the entire menubar before the currently active animation completes, it won't change the to default image mentioned above and you'll be stuck on the other image till you mouse out again slowly. This happens quite often, and results in the animations getting their directions all messed up.
I need a way to use jQuery to halt all other animations in the middle when I mouse out of the entire menu. So whenever your mouse leaves the entire area, cancel all animation and just animate back to the default.
My JS file is minified, but you can take a look here:
http://designsweeter.com/live/bcmedical/wp-content/themes/designsweeter/scripts/menu.js
Beautified JS:
http://designsweeter.com/live/bcmedical/prettymenu.js
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
无法给出具体答案,因为您的代码非常混乱,但请尝试包含此回调。
您需要替换选择器和 .animate 代码以匹配您的具体情况。
希望这有帮助!
Can't give a specific answer cause your code's pretty confusing, but try including this callback.
You'll need to replace the selectors and .animate code to match your specific situation.
Hope this helps!