1

I've got a lot of elements that are different somehow (b,c,d,e,f classes), but each of them has something the same - 'a class'. How to make some animation quene that will make them animate one after another in FIFO order (first in, first out)?

Callback's are going crazy with it as there are many elements and I cant estamine what div will be called when.

2
  • Like this? jsfiddle.net/AZtNu/1 Commented Mar 28, 2013 at 17:30
  • Please don't post questions which contain nothing useful except a JSFiddle. Not how Stack Overflow works. Your question needs to be self contained and answerable without opening any external links. You can then supplement it with a JSFiddle. Commented Mar 28, 2013 at 17:32

3 Answers 3

1

Given that your animations are all the same kind(animating left to 50) but done on multiple elements, you can do it this way:

nextAnim( $('.a') );

function nextAnim(elems) {
    elems.eq(0).animate({'left':50}, function() {
             nextAnim( elems.slice(1) );  // slice off the first element
    });
}

See working fiddle

Sign up to request clarification or add additional context in comments.

Comments

0

Understanding jQuery Deferred.pipe()

You can try to use deferred object if you're feeling like learning something new and doing things in an elegant way.

Comments

0

I've used

$('.a').filter(function(){ return $(this).is(':animated')}).length

to know if any of items is alredy animated, and I'm firing animations only when no of them is animating

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.