I'd count how many elements have the class, and also add an id to each one, incrementing with each count.
Then I would write a function, passing it a randomly generated number (within range of the element count) which would fade in the given id, with a known animation time.
I would then use setInterval to run the function, and give it the same time as the fade animation will take. Could how many times this is ran and once it reaches the amount of elements, end it.
This may also not the best way to do it, but it's better then nested callbacks.
ryan.j wrote:
Hi guys, been playing around with something for a bit this afternoon but i can't find a programatically 'nice' way of achieving the effect i'm after. I have a bunch of elements assigned a class that don't necessarily have anything in common beyond the class. I want to fadeto them in randomly but in-turn, as if i was chaining animation effects for example. http://jsbin.com/exepi the only way i've been able to do this so far is by building and evaluating a slab of nested callbacks which works but is pretty horrible in almost every way. I think i'm missing something fairly obvious here, you guys have any thoughts?