Jump to content
Search Community

onComplete doesn't fire when we are in another tab

Brian Salazar test
Moderator Tag

Recommended Posts

Hi guys I was wondering if there is a way to handle same executing time that setTimeout when we are in another tab? I tried gsap.ticker.lagSmoothing(0); but is faster than setTimeout and the onComplete event does not fire correctly, so I tried TweenLite.ticker.useRAF(false); but I have this error Cannot read property 'useRAF' of undefined, so just need one of two things, that onComplete event works correctly without pause the animation when the user change to another tab or that the animation works in the same way that the setTimeout

Link to comment
Share on other sites

  • Brian Salazar changed the title to onComplete doesn't fire when we are in another tab

Browsers power down requestAnimationFrame, setTimeout(), and setInterval() while the tab is hidden. That's a GOOD thing. It conserves batter and CPU resources. GSAP cannot force the browser not to throttle. Most browsers reduce the refresh rate to about twice per second for hidden tabs. If you want GSAP to continue (at the reduced 2fps rate), you can use the helper function here: 

https://greensock.com/docs/v3/HelperFunctions#hidden

 

If you're still having trouble, please provide a minimal demo so we can see what you're talking about in context. We'd love to help. 

 

And by the way, TweenLite.ticker doesn't exist in GSAP 3. That's from the very old days in v2 and earlier. In fact, TweenLite, TweenMax, TimelineLite, and TimelineMax don't exist - everything was consolidated into a streamlined "gsap" object but there are aliases in place to make most legacy code work. You might want to check out this article:

 

Happy tweening!

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.
×
×
  • Create New...