Jump to content
GreenSock

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

setting progress to a negative makes the timeline go to the end

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

I am getting this issue where if the progress() gets set to something below 0 it goes to the end of the timeline. Is this supposed to happen?

Link to comment
Share on other sites

Yes indeed - that's intentional. It's meant to be a convenience, kinda like String.substr() where if the first parameter is negative, it measures from the END of the string. Likewise, if you've got a 10-second tween and you do this:

 

tween.progress(-0.25);

t'd go 25% back from the end, meaning 7.5 seconds into the animation in this case. 

 

And if you do -0.0001, it'll be almost at the very end. 

 

The same applies for regular time-based methods like time(), totalTime(), and seek(). 

 

Make sense now?

 

If you don't want that behavior, I'd recommend just adding a small piece of conditional logic before your progress() call (or in it) that ensures the value is 0 or positive. 

 

tween.progress( (yourValue < 0) ? 0 : yourValue );
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.
×