rstacruz / jquery.transit

Super-smooth CSS3 transformations and transitions for jQuery
http://ricostacruz.com/jquery.transit
7.29k stars 862 forks source link

Multiple callback on transition for multiple css elements #54

Open Grsmto opened 12 years ago

Grsmto commented 12 years ago

Hi,

I noticed that if you call a transition on multiple elements using Jquery selector, the callback is called twice.

Exemple : $('#element1, #element2, #element3, #element4').transition({ y:"+=30px" }, doSomething);

DoSomething() will be called 4 times instead of 1.

Awesome plugin by the way (should be native in jQuery :) ).

SeanRoberts commented 12 years ago

I just spent a good hour banging my head against a wall because of this. Great plugin but holy cow this should be written in slab text on the front page!

johannesjo commented 11 years ago

Same Problem here. Any ideas on why this happens?

cwmanning commented 11 years ago

For what it's worth, got around this recently.

Multiple callbacks fired:

$('#element1, #element2').transition({ y:"+=30px" }, doSomething);

Single callback fired:

$('#element1, #element2').transition({ y:"+=30px" }).promise().done(doSomething);
kraftwer1 commented 11 years ago

+1

@cwmanning's trick with the promise() works though...

panda4man commented 10 years ago

@cwmanning's trick works perfectly until a fix comes around.