Jump to content
Search Community

Timelinelite forward & reverse motions don't match

captainchemist 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 everyone, 

I am having a problem with making a ball roll down a ramp and then bounce off a block when it hits the bottom. I am including a working version in codepen which will speak many more words than I can, but the problem is that the roll works perfectly when it plays initially, but if I grab the progress bar to readjust it, the ball does not roll back up the ramp but only the Top direction moves, not the Left. I can only fix it by reloading the page.  

 

I can fix this problem by removing the "-=0.05" timing parameter from the last timeline transition, but I feel like I shouldn't have to do that and I am missing something more basic.

 

Thanks so much!

Stephen

 

See the Pen Bpyedz by CaptainChemist (@CaptainChemist) on CodePen

Link to comment
Share on other sites

Looks like you just built things with conflicting tweens. In other words, you had 0.5 seconds when multiple tweens were fighting to control the same property on the same object. By default, GSAP automatically kills the parts of the tweens that are conflicting. That's why that part didn't work in reverse - it had been killed as soon as that other tween started. 

 

You can turn off overwrite protection globally like this:

TweenLite.defaultOverwrite = false;

(or you could set the "overwrite" property on a per-tween basis if you prefer)

 

Or you could just make sure you build your animations so that they're not conflicting :)

 

Does that help?

  • Like 1
Link to comment
Share on other sites

That was super helpful, thank you! Just as a followup, what would be the proper way to write the ball so that it had the rolling & moving behavior as well as the rolling & bouncing behavior? If I just wanted the little bit of bounce at the end, should I really have just ended the first tween after rolling down say 90%, and then having the second tween pick up there at +=0 and continue to roll down the last 10% but add the bounce animation as well? There isn't a way to specify that the bounce animation only turns on 90% through an animation, for example, right?

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