Jump to content
Search Community

"startTime()" of first Tween or Timeline is slightly above zero?

beenjamin

Go to solution Solved by GreenSock,

Recommended Posts

Posted

I prepared a codepen.


Is that a "bug", or is there another function i can use to get the startTime?
Obviously i did not added a delay or a positionParameter etc...
Also i noticed that sometimes startTime is zero.

 

Thanks  a lot for clarification!

See the Pen emYaZyL by Ben-jamin-the-reactor (@Ben-jamin-the-reactor) on CodePen.

Posted

This seems to happen only in the Codepen interface. If you open the debug view (only works with pens you own) cdpn.io/pen/debug/PEN_ID, it is always 0. 

 

Hope it helps and happy tweening! 

 

 

Posted

thanks for the quick answer.
actually i have tried it localy in a browser, and there is the same problem. 😕

Posted

Hi,

 

I tried this locally quite a few times and I never got any number different than 0 neither in my desktop nor laptop, even when clearing the cache.

 

A possible reason could be that it takes some time to parse and execute the JS code and that could be the cause here. Granted is just a few milliseconds (no more than 2 or 3) which is not the numbers you get on the codepen demo.

 

Also is worth clearing that the start time value represents the point where the particular instance starts on it's parent instance, in this case you have a single timeline that resides in the global timeline:

https://gsap.com/docs/v3/GSAP/gsap.globalTimeline

 

The global timeline most likely, is created ahead of that particular code being run, when the GSAP core file is loaded in the page. During that time the global timeline is active and moving forward, so if there is some time that elapses between the global timeline being created and the timeline instance being instantiated and added to the global timeline, that is the value you're getting because at that time the Tween/Timeline is being added to the global timeline. In some build systems, like codepen for example, that can take more time than others.

 

Is this becoming a problem in your GSAP implementation somehow, or you're just curious about the value you're getting?

 

Hopefully this clear things up

Happy Tweening!

  • Like 1
  • Solution
Posted

Yep, like @Rodrigo explained, that's completely normal and expected. GSAP's global timeline begins the moment the core file is loaded, but your code that creates the timeline/tweens may not get run by the browser for a short time after that. It's not a bug or malfunction at all. 100% expected.

 

I echo Rodrigo's question - why are you concerned about the startTime() value? Is there some practical issue you're running into? 

Posted

thanks for the explanation!
Nothing special, i was just wondering and was playing around with all that gsap has to offer.
good to hear that this is not a bug 🙂👍

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