Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

.complete is called twice. Before and after a transition #135

Open
dan-lee opened this issue May 31, 2013 · 8 comments
Open

.complete is called twice. Before and after a transition #135

dan-lee opened this issue May 31, 2013 · 8 comments

Comments

@dan-lee
Copy link

dan-lee commented May 31, 2013

My .complete callback is called before the transition and after.
I have to use this workaround to use it under current circumstances:

var c = 0;
el.transition({
  // ...
  complete: function() {
    if (++c % 2 == 0) {
      // ...
    }
  }
});
@matthew-dean
Copy link

Yep, having the same issue.

@dan-lee
Copy link
Author

dan-lee commented Jun 5, 2013

Okay, this bug appears to be a bug of this pull request: #134

@nibblebot
Copy link

critical issue....

@skevy
Copy link

skevy commented Jun 17, 2013

Up vote on this one.

skevy added a commit to chalkchisel/jquery.transit that referenced this issue Jun 17, 2013
skevy added a commit to chalkchisel/jquery.transit that referenced this issue Jun 17, 2013
@hannesjohansson
Copy link

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

See:
#170

@rolbr
Copy link

rolbr commented Oct 18, 2013

+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 ;)

@hannesjohansson
Copy link

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

@okonet
Copy link

okonet commented Jun 25, 2014

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants