Jump to content
GreenSock

Search In
  • More options...
Find results that contain...
Find results in...
martis

Pause all timelines when page is not "focus" safari iOS

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

Heya,

 

I am running into an issue on one of my sites where when I navigate away (open a new tab) and come back to my tab my animations are out of sync. Does anyone know a way to detect if the user has navigated away, and navigated back? Tried blur and unload on window, but no luck...

Link to comment
Share on other sites

Hello martis..

 

Here is an example that checks for window focus / blur events. It also checks for browser tab focus and blur using HTML5 Visibility API .. so you can pause() and resume() the animation on window tab focus / blur:

 

See the Pen sxgJl by jonathan (@jonathan) on CodePen

 

does that help? :)

Link to comment
Share on other sites

Does it work for safari on iPhone and iPad?

Link to comment
Share on other sites

It worked when I first tested and made that codepen, which wasnt that long ago.. it works in Modern Browsers and mobile browsers.

 

But If you go to that codepen link I referenced above, you can test it on your IPhone or IPad you might have to open the pen in Full View.. just follow the short directions in the codepen, which is just simply focusing in and out by switching tabs and browser windows:

 

See the Pen sxgJl by jonathan (@jonathan) on CodePen

 

So it's best to test it on your devices.. Also I'm sure that some of the fine minds here who have looked at that codepen above can share how it behaved on their IPhone or IPad ;)

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