Jump to content
GreenSock

gsapnoob

[solved] TweenLite animation stops when window lost focus

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

Hey guys, I am new to this, so the question is maybe stupid.

I am moving an object within my canvas using TweenLite. Works perfectly, but when I open another page, animation stops. It there a way to prevent that? I want my animations to work even if focus is lost.

See the Pen mJWVwE by anon (@anon) on CodePen

Link to comment
Share on other sites

Hi and welcome to the GreenSock forums.

 

Its a great question, and thanks for the demo, it was very helpful.

 

When it appears that your animation pauses when you lose focus its actually a feature that is great for preserving resources (especially on mobile devices).

The engine's ticker is tied to requestAnimationFrame so that the engine will automatically "power down" when the tab loses focuses and resume when focus comes back.

 

If you want your animations to keep running, you can turn off RAF and lagSmoothing() like so

 

  TweenLite.ticker.useRAF(false);
  TweenLite.lagSmoothing(0);
  • Like 2
Link to comment
Share on other sites

Worked like a charm, thank you!

  • Like 1
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.
×