Ilja Posted January 17, 2021 Share Posted January 17, 2021 I am working on a game that has timer that is animating down, it indicates how much time player has left to make their move. Gsap is animating this timer. Issue I am currently facing is that if player goes to a different browser tab gsap seems to stop animating the timer. After some research I believe this is by design and feature responsible for this is "lagSmoothing" I was able to disable this via "gsap.ticker.lagSmoothing(0)". However this disables lag smoothing for my whole app. I was trying to look similar method on "TimelineLite" that I am using for timer animation, but wasn't able to find anything. Hence this question: Can I disable lagSmoothing for single timeline as opposed whole app? Here is an example of how timeline lite is used in my app. import { TimelineLite } from 'gsap' const timeline = new TimelineLite() this.timeline.to(this, { /* animation config*/ }) Link to comment Share on other sites More sharing options...
mikel Posted January 17, 2021 Share Posted January 17, 2021 Hey @Ilja, Have you seen this thread "That's pretty unusual, but I suppose you could do that logic your own separately. Like you'd have to use Date.now() and when the tab becomes unhidden, do some comparisons to see how much time elapsed and set the progress() on your animation accordingly." And you should also migrate to the new GSAP 3 syntax. Happy tweening ... Mikel 3 Link to comment Share on other sites More sharing options...
Ilja Posted January 17, 2021 Author Share Posted January 17, 2021 @mikel Ah, listening to document event for this and toggling lagSmoothing works and makes a lot of sense actually. Just a follow up question are defaults for lagSmoothing still lagSmoothing(500, 33) as in that question, or other values should be used to re-enable it? Link to comment Share on other sites More sharing options...
mikel Posted January 17, 2021 Share Posted January 17, 2021 Hey @Ilja, There is only one explanation in the GSAP 2.0 DOCs. But I don't know how it behaves in new GSAP 3.0. @GreenSock or @ZachSaucier will comment on this. Happy tweening ... Mikel Link to comment Share on other sites More sharing options...
akapowl Posted January 17, 2021 Share Posted January 17, 2021 @Ilja I was digging through this myself this weekend, and stumbled upon this in the v3 docs For example, if the threshold is 500 and the adjustedLag is 33 (those are the defaults) [...] [...] This feature is already activated by default, using a threshold of 500ms and a adjustedLag of 33ms https://greensock.com/docs/v3/GSAP/gsap.ticker#lagSmoothing 3 Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now