Skip to main content

.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"});




Comments

  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

Post a Comment

Popular posts from this blog

Why is this Javascript much *slower* than its jQuery equivalent?

I have a HTML list of about 500 items and a "filter" box above it. I started by using jQuery to filter the list when I typed a letter (timing code added later): $('#filter').keyup( function() { var jqStart = (new Date).getTime(); var search = $(this).val().toLowerCase(); var $list = $('ul.ablist > li'); $list.each( function() { if ( $(this).text().toLowerCase().indexOf(search) === -1 ) $(this).hide(); else $(this).show(); } ); console.log('Time: ' + ((new Date).getTime() - jqStart)); } ); However, there was a couple of seconds delay after typing each letter (particularly the first letter). So I thought it may be slightly quicker if I used plain Javascript (I read recently that jQuery's each function is particularly slow). Here's my JS equivalent: document.getElementById('filter').addEventListener( 'keyup', function () { var jsStart = (new Date).getTime()...