Jump to content
Search Community

onComplete not firing?

1DMF test
Moderator Tag

Warning: Please note

This thread was started before GSAP 3 was released. Some information, especially the syntax, may be out of date for GSAP 3. Please see the GSAP 3 migration guide and release notes for more information about how to update the code to GSAP 3's syntax. 

Recommended Posts

Hi,

 

my onComplete doesn't appear to be firing, please can someone advise why.

TweenLite.fromTo(obj,1, {height:minHeight+curHeight},{height:minHeight, onCompleteParams:[obj], onComplete:function(obj){obj.toggleClass('active')}});

Thanks

1DMF

Link to comment
Share on other sites

Well I replaced the anonymous function with a real one and it's working?

 

Though the params don't seem to work, so I've done it like this...

TweenLite.fromTo(obj, 1, {height:minHeight+curHeight}, {height:minHeight, onComplete:toggle(obj)});

Regards,

1DMF

Link to comment
Share on other sites

However, I have just found that the onComplete is firing instantly and not on completion of animation?

 

What am I doing wrong?

 

UPDATE:

 

OK, so if you use parentheses and try to pass in arguments or void, the function fires immediately, so I went back to onCompleteParams and found that they must follow the onComplete special property.

 

In my original example I had the onCompleteParams before the onComplete, which appears not to work.

 

This is now working as desired...

TweenLite.fromTo(obj, 1, {height:minHeight+curHeight}, {height:minHeight, onComplete:toggle, onCompleteParams:[obj]});
Edited by 1DMF
Link to comment
Share on other sites

The order shouldn't matter at all. 

 

I bet there was something else going on in your code previously that caused things not to work, but I'm glad to hear it's working for you now. If you can show us a way to reproduce the faulty behavior, please do. Otherwise, good luck with the project. Happy tweening.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...