我有一个调用两个动画 Action 的事件监听器。不幸的是,它们的开始有少量错开(例如,函数中的第一个首先开始)。
有谁知道正确同步它们的方法吗?
这是我的代码:
$("#nav ul li a").hover(
function(){
$(lastBlock).children("div").animate({width: "0px"}, { queue:false, duration:400, easing:"swing" });
$(this).children("div").animate({width: maxWidth+"px"}, { queue:false, duration:400, easing:"swing"});
lastBlock = this;
}
);
因为第一个动画稍微早于第二个动画,它导致整体宽度暂时变得不相等,这看起来有点古怪。
最佳答案
最近在 jQuery 开发人员列表上有一个关于这个确切主题的讨论。他们创造了一个 few test cases你可能想看看。 Specially the Johns test.
Here's顺便说一下讨论主题。
关于javascript - 有没有办法让两个 jQuery 动画同时(正确地)运行?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/687495/