【问题标题】:Multiple jquery animate's with same speed and different height's complete the animation at the same time多个jquery动画以相同的速度和不同的高度同时完成动画
【发布时间】:2012-02-04 05:42:35
【问题描述】:
【问题讨论】:
标签:
jquery
jquery-animate
【解决方案1】:
下面是我的做法:
//Calculate length of time per pixel
var spp = 500/20;
$('#lt').animate({ height: '400' }, spp*400, 'linear');
$('#mm').animate({ height: '55' }, spp*51, 'linear');
$('#ss').animate({ height: '20' }, spp*20, 'linear');
您更新的 jsfiddle:http://jsfiddle.net/CEksN/8/
【解决方案2】:
这是一个修改版,我对高度和速度做了一个简单的改变,这样两者的比例就更明显了……
$('#lt').animate({ height: '400' }, 1600, "linear");
$('#mm').animate({ height: '200' }, 800, "linear");
$('#ss').animate({ height: '100' }, 400, "linear");
我还制作了线性动画,以便您可以看到它们以相同的速度制作动画。删除“线性”参数,它看起来就不那么均匀了。恐怕这只是宽松的本质。它看起来很可爱,但在同步你想要的东西时可能会导致数学问题。
希望这会有所帮助:)