http://codepen.io/Snowfiring/pen/oKpBh
我试图在点击时禁用动画,因为当点击时,动画开始移动,如果你仍然悬停在它冻结的对象上,最终结果是动画停止运行,它只是移动,
我用来冻结悬停动画的代码是
function show_box() {
if($(window).width() > 768) {
$('.tab-content').hide(0,
function() {
$(this).prev().css('right', '29.337803855%');
$(this).prev().children().children().click(function () {
$('.favorite').off('mouseenter').css('-webkit-animation-play-state', 'running');
$('.secret').off('mouseenter').css('-webkit-animation-play-state', 'running');
$('.current-projects').off('mouseenter').css('-webkit-animation-play-state', 'running');
$('.tab-selection').animate({right: 0}, 3000).queue(function() {
$('.tab-content').show(1000);
});
$('.favorite').on('mouseenter');
$('.secret').on('mouseenter');
$('.current-projects').on('mouseenter');
});
}
);
}
}要禁用mouseenter和mouseleave上的悬停,我使用
.off('mouseenter')但在函数完成并完成移动后,我设置了
.on('mouseenter')但它不会重新启用。
发布于 2014-04-13 06:59:35
一开始,我认为你的代码可能会短得多。
请在jQuery文档中查看它没有的on功能,这是您所期望的!
我认为你应该设置一个全局变量,如果它现在是禁用的,在晚上,你首先检查这个变量,如果它被禁用,就放弃它。
https://stackoverflow.com/questions/23037091
复制相似问题