Jump to content


progress question about duration 0 tweens

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

In my example, shouldn't progress in an onUpdate callback for a 0 duration tween return 1?

See the Pen mHvFj by jedierikb (@jedierikb) on CodePen

Edited by erikb
Link to comment
Share on other sites

Zero-duration tweens are an odd concept because they're not really tweens at all. And when the playhead lands directly on top of one, should that be interpreted as its "beginning" or "end" (there isn't really such a thing when there's no duration). See what I mean? We have done a lot of work to accommodate them, though, mostly by looking at the direction of the playhead as well as a few other factors, so they should behave in an intuitive way. 


I've never seen someone try what you're doing before, but I've added some code to resolve that in the next release. No problem. For now, you can simply check the tween's "ratio" instead (it'll be 1 at the end of a 0-duration tween, and 0 at the beginning). Keep in mind that the ratio is a number that's affected by the easing; it's not linear like progress is. 

  • Like 3
Link to comment
Share on other sites

Thanks!  I've many tweens where sometimes they have >0 durations, but sometimes they have to just jump to their destinations.  


I could check for duration before tweening and call set or to depending.  But it feels cleaner to just use duration 0.

Link to comment
Share on other sites

Oh, it's fine to use a duration of 0 in a to() instead of set() - the result is exactly the same thing. A set() is just a zero-duration to() call internally anyway. 

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.