1DMF

onComplete not firing?

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

Share this post


Link to post
Share on other sites

No idea; that looks fine to me. It would help if you made a demo showing this issue in codepen or jsfiddle so we could investigate.

Share this post


Link to post
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

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

Ah cool thanks for replying with your results. I'd never tried ordering them that way before and just assumed it would work

 

...which it does.......

Share this post


Link to post
Share on other sites

No problem, I absolutely love GSAP and hope it helps others.

Share this post


Link to post
Share on other sites

Hmmm.. that is weird .. I just made an example of the placement of onComplete after the onCompleteParams .. in a fromTo() and the onComplete fires as expected:

 

http://codepen.io/jonathan/pen/xtkej

 

Do you see it too?

Share this post


Link to post
Share on other sites

Yea totally working for me too. It's even working when I copy the exact tween (with valid height values) into your pen

 

http://codepen.io/anon/pen/lnItb

 

Back to square one - we have no idea why that didn't work for you...

  • Like 1

Share this post


Link to post
Share on other sites

yep,  your pen works for me too Jamie :blink:

Share this post


Link to post
Share on other sites

? who knows.. all working now, so all good :-)

Share this post


Link to post
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.

Share this post


Link to post
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.