As I currently understand $("#someElement").animate() it will execute asynchronously relative to any other JavaScript statements. For instance:
$("#anotherElement").css("display", "none");
$("#someElement").animate();
//Setting the CSS display may fire AFTER the animation takes place.
If I am correct in my understanding of how开发者_如何学JAVA animations work, how do I:
- Make the animations run synchronously with the rest of my code?
- If I have animations that I'd like to order that affect different elements how do I synchronize them to run in a given order?
Thanks for the help.
- No, you can not run animation synchronously (callbacks only).
- Use callbacks for this behaviour.
Sample:
$('#elem1').animate(params, function () {
$('#elem2').animate(params, function () {/* ...other elements */});
});
精彩评论