Open dan-lee opened 11 years ago
Yep, having the same issue.
Okay, this bug appears to be a bug of this pull request: rstacruz/jquery.transit#134
critical issue....
Up vote on this one.
If you want to be compatible with jQuery animate, you should pass the complete call in the second object parameter
var c = 0;
el.transition({
// ...
},
{
complete: function() {
if (++c % 2 == 0) {
// ...
}
}
});
+1
Since the docs (https://github.com/rstacruz/jquery.transit#animating---fntransition) explicitly state that you can define the complete-callback within the first object, I wasn't hesitating to do exactly that, which resulted in the callback being called twice.
However, putting the complete-callback into the second object just as hannesjohansson pointed out above, does indeed remedy this issue.
I love adding everything to the first object though, because it looks much cleaner ;)
I agree that it is cleaner but it completely breaks compatibility with jquery.animate. If you put the callback inside of the first object in animate it doesn't run, so the documentation for transit is kind of flawed.
Example of jQuery not accepting a callback function in the first object param: http://codepen.io/anon/pen/fErzb
Following semver, no matter what decision will be made on jQuery.animate
compatibility issue (#170), this breaking change should be fixed and released as a next patch version. And if the decision will be made to break the current API, there should be a separate release under at least next minor version.
Right now everybody who is using npm's and bower's defaults to define dependencies in *.json
files like ~x.x
or ^x.x
is experiencing lots of pain and frustration!
My
.complete
callback is called before the transition and after. I have to use this workaround to use it under current circumstances: