Friday, February 17, 2012

.animate() queue option explanation


from http://api.jquery.com/animate/ :




queue: A Boolean indicating whether to place the animation in the effects queue. If false, the animation will begin immediately. As of jQuery 1.7, the queue option can also accept a string, in which case the animation is added to the queue represented by that string.




I want that the animations added to an object should be start when the last animation ends. From the jquery doc it seems to me that, in order to achieve this, the animation must added to a queue. if I pass {queue: true} the animation is added to the general queue, while in jQuery 1.7 I can pass {queue: "queue_foo"} to add the animation to a certain queue. I wrote this in my code, but the animation is not executed.




showedSlide.animate({
left: -showedSlide.outerWidth()
}, {queue: "left"});

1 comment:

  1. The default queue ('fx') gets dequeued immediately whenever a new action gets queued, custom queues do not. You have to dequeue() them yourself.

    I suspect, however, that you tried the default queue, it didn't work and so you turned to custom queues, because unless you specify queue: false animations do get queued up, and the next animation waits for the previous one to complete before it can begin. But this only applies to animations on a single element. If you have 2 animations on 2 different elements, they'll execute in parallel.

    Does your showedSlide always refer to the same element or does it change?

    ReplyDelete