有没有什么办法,使运行(正常)同时在两个jQuery的动画? [英] Is there any way to make two jQuery animations run (properly) simultaneously?
问题描述
我有一个事件侦听器调用两个动画动作。不幸的是他们开始用少量的交错(例如,在函数的第一个启动在前)。
I have an event listener that calls two animation actions. Unfortunately their starts are staggered by a small amount (e.g. the first in the function starts first).
有谁知道一种方法来正确地同步起来?
Does anyone know a way to properly sync them up?
下面是我的code:
$("#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;
}
);
由于第一动画第二稍前运行,它会导致整体的宽度成为一时的不平等,这看起来有点古怪。
Because the first animation runs slightly before the second, it causes the overall width to become momentarily unequal, which looks a bit funky.
推荐答案
有大约jQuery的开发列表上的这个确切的话题最近disussion。他们创造了一个一些测试用例你可能想看看在。 特别约翰考验。
There was a recent disussion about this exact topic on the jQuery dev list. They created a few test cases you might wanna look at. Specially the Johns test.
这里的的讨论话题顺便说一句。
Here's the discussion topic btw.
这篇关于有没有什么办法,使运行(正常)同时在两个jQuery的动画?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!