Jump to content


zero length tween in timeline firing immediately

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

Got snagged by having a zero duration tween in a timeline fire before it should.


Worked around it by setting a duration really close to zero.


Bug?  Thanks.

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

Link to comment
Share on other sites

Nope, that's not a bug - zero-duration tweens render immediately by default. That's what most people find the most intuitive, otherwise if you set() something and then had a line of code right after that which depended on that set() having been applied, it wouldn't work. See what I mean? 


All you need to do is set immediateRender:false -OR- you can do a set() directly on the timeline instance because in that case, it can tell if you're scheduling it for later. the problem with your example was that you were creating an independent tween (outside the timeline) and when that's created, there's no way for it to know that you're planning to add that to a timeline in the future, and schedule it further out. The timeline set() convenience method has the benefit of knowing that, thus it'll set immediateRender:false for you (unless it's at the very beginning of the timeline). 


Make more sense now? 

  • Like 4
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.