如何停止jquery悬停滑动切换队列
我试图创建一个水平菜单,当鼠标悬停时,它会向上展开。 问题是当你在它们上面快速盘旋时,它们会产生一种可怕的跳跃效果,看起来很恶心。如何防止这种情况发生,还有没有更好的方法来编写此函数如何停止jquery悬停滑动切换队列,jquery,queue,slidetoggle,Jquery,Queue,Slidetoggle,我试图创建一个水平菜单,当鼠标悬停时,它会向上展开。 问题是当你在它们上面快速盘旋时,它们会产生一种可怕的跳跃效果,看起来很恶心。如何防止这种情况发生,还有没有更好的方法来编写此函数 $(".toggle_hov").hover(function () { $(this).find(".toggle_cont").stop().slideToggle(); $('.toggle_hov.active').not(this).removeClass('active');
$(".toggle_hov").hover(function () {
$(this).find(".toggle_cont").stop().slideToggle();
$('.toggle_hov.active').not(this).removeClass('active');
$(this).toggleClass('active');
var $this = $(this).parent().find('.toggle_cont');
$(".toggle_cont").not($this).slideUp();
});
非常感谢
我建议你在悬停中使用一些延迟,如果用户在给定的时间内悬停,它只会打开幻灯片。如果你快速移动它,它就不会滑开
var delay=500, setTimeoutConst;
$(".toggle_hov").hover(function () {
that = $(this);
setTimeoutConst = setTimeout(function () {
$(that).find(".toggle_cont").slideToggle();
$('.toggle_hov.active').not(this).removeClass('active');
$(that).toggleClass('active');
var $this = $(this).parent().find('.toggle_cont');
$(".toggle_cont").not($this).slideUp();
}, delay)
}, function(){
clearTimeout(setTimeoutConst );
});
这是stoptrue???clearQueue也能工作非常感谢,stoptrue工作得最好!jsfiddle.net/Js5Z5/2