Reputation: 8104
I have these two things happen in my jQuery-animated website:
$('#myFirstDiv').animate({top: "15%"}, 3000);
$('#mySecondDiv').animate({bottom: "15%"}, 3000);
These two animations seem to happen one after another, rather than simultaneously. There's a slight delay before the second one plays, about one tenth of a second. I want to make them occur simultaneously.
I tried this:
$('#myFirstDiv').animate({top: "15%"}, 3000);
$('#mySecondDiv').animate({bottom: "15%"}, {duration:3000, queue: false});
but it's probably wrong.
I would appreciate advice on how to do this correctly.
Upvotes: 1
Views: 1086
Reputation: 2837
Your code should work just fine. Animation in jQuery is asynchronous, this means that if you have two animation calls, the second one will get called right after the first one even though the first animation is still in progress. If at any point you want to have the first one to execute to the end before the second one, your code will look like
$('#myFirstDiv').animate({top: "15%"}, 3000, function(){
$('#mySecondDiv').animate({bottom: "15%"}, 3000);
});
Upvotes: 2