Dips
Dips

Reputation: 3290

Animate a div without slowing down

I have a div which has 2 animation one after another. But once first animation finishes it slows down and run another animation. I don't want the div to slows down in between the animation, I want them run at same speed.

$(".div1").animate({'left':'+=200'},2000);
$(".div1").animate({'top':'+=200'},2000);

Here is I have set up on jsfiddle http://jsfiddle.net/WQDm8/

Let me know if this doesn't make sense. thanks

Upvotes: 0

Views: 435

Answers (2)

DanRedux
DanRedux

Reputation: 9349

Not quite. It's because each animate is added to the queue. Do them at the same time.

$(".div1").animate({left:'+=200',top:'+=200'},2000);

Upvotes: 0

rjz
rjz

Reputation: 16510

I think the behavior you're looking for can be accomplished by changing the easing parameter described in the documentation for .animate() to linear:

$(".div1").animate({'left':'+=200'},2000, 'linear');
$(".div1").animate({'top':'+=200'},2000, 'linear');

Upvotes: 2

Related Questions