取消所有排队的 jQuery slideUp 和 slideDown 动画 [英] Cancel all queued jQuery slideUp and slideDown animations

查看:34
本文介绍了取消所有排队的 jQuery slideUp 和 slideDown 动画的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个界面,它大量使用 jQuery slideUp 和 slideDown 效果以一种三态的方式扩展项目.

I have an interface that makes heavy use of the jQuery slideUp and slideDown effect to expand items in a tri-state kind of way.

onmouseover: function() { 
this.find('.details', this).slideDown(); 
},
onmouseout: function() { 
this.find('.details', this).slideUp(); 
}

但是,当用户将鼠标快速移动到这些界面元素上时,动画跟不上,并且在鼠标离开界面区域后,项目会上下滑动很长时间.

However, when the user quickly moves the mouse over these interface elements the animations can't keep up and the items will be sliding up and down long after the mouse has left the interface area.

当鼠标离开项目的容器 div 时,有没有办法取消所有排队的幻灯片动画?

Is there a way to cancel all the queued-up slide animations when the mouse leaves the item's container div?

推荐答案

我相信你应该能够只添加一个 .stop() 并且它会为你解决这个问题:

I believe you should be able to just add a .stop() and it'll take care of that for you:

onmouseover: function() { 
this.find('.details', this).stop().slideDown(); 
},
onmouseout: function() { 
this.find('.details', this).stop().slideUp(); 
}

这篇关于取消所有排队的 jQuery slideUp 和 slideDown 动画的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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