所以我试图编码这个导航,并得到它的所有工作,除了有时JQuery动画或者打破或者如果你太快地移动你的鼠标是跳动。在Safari中它看起来也非常可怕,它似乎几乎闪动了动画?JQuery动画凌乱
$(document).ready(function() {
// On hover:
$('#navigation li').hoverIntent(function() {
width = $(this).children('span:nth-child(2)').width();
text = $(this).children('span:nth-child(2)');
var newwidth = (width + 15) // Original width + 15px padding
text.animate({"width":"0px"}, 0).show(); // Make the width 0px and make the element visible
text.animate({"width":+newwidth+"px"}, 300); // Animate the width to the new size
},
function() {
text.animate({"width":"0px"}, 300); // Animate the width to 0px and hide the element
text.animate({"width":+width+"px","float":"left"}, 0);
setTimeout(function() {
text.hide();
}, 300);
});
});
下面是它的一个JFiddle:
此外,实时预览,所以你可以看到它实际上是这样的:
http://dev.evaske.com/Navigation/
如果有人将鼠标悬停在其上,然后在文本闪烁进入和退出的过程中很快地将鼠标悬停在它上面,有没有办法阻止它? – Tenatious 2013-03-06 11:00:02
也许吧。 :)这是你期望用户参与的那种交互行为吗? – 2013-03-06 13:26:06