jquery动画之间的短暂延迟。为什么?

时间:2013-04-16 13:37:27

标签: jquery

$("#car_overtake5").animate({path : new $.path.arc(arc_params)}, {duration: 2000, queue: false});
$("#car_overtake5").animate({rotate: '109deg'}, {duration: 2000, queue: true});
$("#car_overtake5").animate({"left":"9872px","top":"4872px"}, {duration: 1000, queue: true});
$("#car_overtake5").animate({rotate: '94deg'}, {duration: 250, queue: true});
$("#car_overtake5").animate({"left":"10939px","top":"4948px"}, {duration: 1000, queue: true});

汽车正在赛道上动画。但是在每个动画之后它停止了很短的时间然后播放下一个动画。

如何让他们毫不拖延地让他们流利地玩?

编辑:将缓和更改为线性,现在没有延迟。

2 个答案:

答案 0 :(得分:2)

默认缓动设置为“swing”,因此请尝试将其更改为“linear”:

$("#car_overtake5")
     .animate({path : new $.path.arc(arc_params)}, {duration: 2000, queue: false, easing: "linear"})
     .animate({rotate: '109deg'}, {duration: 2000, queue: true, easing: "linear"})
     .animate({"left":"9872px","top":"4872px"}, {duration: 1000, queue: true, easing: "linear"})
     .animate({rotate: '94deg'}, {duration: 250, queue: true, easing: "linear"})
     .animate({"left":"10939px","top":"4948px"}, {duration: 1000, queue: true, easing: "linear"});

答案 1 :(得分:1)

jQuery每次都必须在DOM中查找#car_overtake5。这会导致延迟,特别是在大规模的项目中#34;如你所说。使用此:

$("#car_overtake5").animate({path : new $.path.arc(arc_params)}, {duration: 2000, queue: false})
        .animate({rotate: '109deg'}, {duration: 2000, queue: true})
        .animate({"left":"9872px","top":"4872px"}, {duration: 1000, queue: true})
        .animate({rotate: '94deg'}, {duration: 250, queue: true})
        .animate({"left":"10939px","top":"4948px"}, {duration: 1000, queue: true});