我正在使用本教程创建一个翻转墙:http://tutorialzine.com/2010/03/sponsor-wall-flip-jquery-css/
在本教程中,触发器元素是由.click事件触发的,我想将其更改为.mouseover事件。
我已经在这里设置了一个使用.mouseover事件的演示。但是,当您悬停在图像上并稍微移动鼠标时,图像就会向后翻转。
这是我的js:
编辑:更新的代码
$(document).ready(function(){
var valid = false;
$('.sponsorFlip').bind("mouseenter",function(){
elem = $(this);
if(!valid){
// Using the flip method defined by the plugin:
elem.flip({
direction:'lr',
speed: 250,
onBefore: function(){
// Insert the contents of the .sponsorData div (hidden from view with display:none)
// into the clicked .sponsorFlip div before the flipping animation starts:
elem.html(elem.siblings('.sponsorData').html());
}
});
// Setting the flag:
elem.data('flipped',true);
valid = true;
}
});
$('.sponsorFlip').bind("mouseleave",function(){
elem = $(this);
elem.revertFlip();
valid = false;
});
}); 有谁知道当你轻轻移动鼠标时如何防止翻转吗?我希望这个元素保持翻转,直到鼠标离开那个元素。
发布于 2013-07-25 22:00:40
我认为,当您快速悬停时,元素再次翻转出现问题的原因是,悬停事件是在当前事件结束之前触发的。
我建议在这里使用停止播放 jQuery方法:
elem.stop().flip({不幸的是,这仅仅是一半的解决方案,因为这样你就有了动画被提前切断的问题。抱歉,我不知道该怎么防止。希望这将帮助您找到一个更永久的解决方案。
您可能会发现这篇文章很有用:http://css-tricks.com/full-jquery-animations/
https://stackoverflow.com/questions/17854532
复制相似问题