By default the jQuery queue that is created for animate() is done per element, I\'m wondering if there is a way to create a single queue for all animations done with animate()?
Something like this:
$(someElement) // could also be a plain object, e.g. $({})
.queue('customQueue', function (next) {
first.animate({ ... }, function () {
// when the animation is complete, call next() for customQueue
next();
});
})
.queue('customQueue', function (next) {
second.animate({ ... }, function () {
// when the animation is complete, call next() for customQueue
next();
});
})
// add more animations, then
.dequeue('customQueue');
.animate()
has a queue
option that will only allow one effect per element:
queue: A Boolean indicating whether to place the animation in the effects queue. If false, the animation will begin immediately.
$('div').animate({ height: 50, queue: false });
You could do it with your own custom queue on one element using queue:
http://jsfiddle.net/jRawX/2/
$(function(){
$('#myQueue')
.queue('myQueue',function(next){
$('#t1').animate({left: 100},
{duration: 1000,
queue: false,
complete: next
})
})
.queue('myQueue',function(next){
$('#t2').animate({left: 100},
{duration:1000,
queue:false,
complete: next})
})
/* etc. */
.dequeue('myQueue')
})