In many cases I wish animation to be executed synchronously. Especially when I wish to make a a series of sequential animations.
Is there an easy way to make a jQuer
jQuery cannot make synchronous animations.
Remember that JavaScript runs on the browser's UI thread.
If you make a synchronous animation, the browser will freeze until the animation finishes.
Why do you need to do this?
You should probably use jQuery's callback parameter and continue your method code in the callback, like this:
function doSomething() {
var thingy = whatever;
//Do things
$('something').animate({ width: 70 }, function() {
//jQuery will call this method after the animation finishes.
//You can continue your code here.
//You can even access variables from the outer function
thingy = thingy.fiddle;
});
}
This is called a closure.