Jump to content
GreenSock

Search In
  • More options...
Find results that contain...
Find results in...
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:

 

See the Pen xtkej by jonathan (@jonathan) on CodePen

 

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

 

See the Pen lnItb by anon (@anon) on CodePen

 

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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

  • Recently Browsing   0 members

    No registered users viewing this page.

×