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 provides a "step" callback for its .animate() method. You can hook into this to do synchronous animations:
jQuery('#blat').animate({
// CSS to change
height: '0px'
},
{
duration: 2000,
step: function _stepCallback(now,opts) {
// Stop browser rounding errors for bounding DOM values (width, height, margin, etc.)
now = opts.now = Math.round(now);
// Manipulate the width/height of other elements as 'blat' is animated
jQuery('#foo').css({height: now+'px'});
jQuery('#bar').css({width: now+'px'});
},
complete: function _completeCallback() {
// Do some other animations when finished...
}
}