Jump to content
GreenSock

Search In
  • More options...
Find results that contain...
Find results in...
zimbeta

Callback function in a timeline fires before complete

Recommended Posts

Hi Greensock gurus. Been struggling with timing this animation properly. It's business data interactive and I'd like the HTML to be updated from a content object but only at certain intervals. Please see my pen.  

 

Press button "Step 2" or "Step 3."  I want the content of the HTML to update to step 2 description but not until the timeline animation has finished. Why is this onComplete function callback not waiting until the element has stopped moving to change? The idea is the animation will move off the screen or text fade out, then update, then I bring it back in. 

 

Any help or just a general idea? Thanks so much 

 

Pete

See the Pen BqdmXV by zimbeta (@zimbeta) on CodePen

Link to comment
Share on other sites

It looks like the problem is that you've got CSS transitions applied. So every time GSAP changes a property, CSS transitions say "wait! don't do that yet...I'll take 2 seconds and animate those in". So GSAP was doing exactly what you told it to do, and the onComplete was firing appropriately...but your CSS transitions were taking another 2 seconds after that. 

 

See what I mean? 

 

I'd strongly recommend avoiding CSS transitions/animations if you're going to use GSAP to animate things. :)

  • Like 4
Link to comment
Share on other sites

This is what happens when you tell CSS and JavaScript to animate the same thing.

 

2Rqgaer.gif

 

 

 

  • Like 2
  • Haha 5
Link to comment
Share on other sites

Many thanks Jack! I had some leftovers from a previous animation attempt and it was interfering. Now that's I've removed them it seems to work properly. 

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.
×