Jump to content
GreenSock

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

NON-stopping tween when switched tab is still unresolved?

Recommended Posts

When the browser tab is switched, tween also pauses, and yes, this is a feature.

But also the opposite is also very common need!

- Switched to other tab

- Returned to our tab after some time.

- Tweens (or some tweens) are updated as if the tab was never switched, without losing the advantage of RAF.

 

I have found same questions, like this one: http://greensock.com/forums/topic/9887-tween-paused-when-switch-to-other-tabs/

 

(And I think much more newbies will ask the same again, since this is also commonly desired feature too!)

 

The proposed solutions were some workarounds, like RAF, lagSmoothing, etc.

 

My question is if as of the version 1.18.x the solution is still those workarounds, or there is finally a nice solution.

 

Thanks.

Link to post
Share on other sites
My question is if as of the version 1.18.x the solution is still those workarounds, or there is finally a nice solution.

 

 

Hm, was there something about those solutions that wasn't "nice"? Please describe what a "nice" solution would be in your opinion. (I don't mean that in a defensive way - I'm just trying to understand how we could help better or why the existing solutions are less than desirable).  

Link to post
Share on other sites

Sure, I also did not mean in an offensive way. What I meant with "nice" is:

Those workaround solutions have their -expensive- price, ie, losing RAF and/or lagSmoothing.

And what about detecting focus on/off? Well, that is the way that one would do also without GS.

 

If in GS such feature was added, it would be optimized I guess, somehow better than the workarounds.

I just wanted to know if this happened, since the answers that I found was rather old (about version 1.12.x).

 

Maybe in later versions we'll have that chance.

 

Thanks.

Link to post
Share on other sites

I see what you mean. The challenge is that what you're asking for isn't really a core animation feature and VERY few people need/want it, so it's difficult to justify the kb expense of adding it right into the core, especially because it can already be achieved pretty easily outside the engine. See what I mean? Every time we add a feature to the core, it exacts a cost on every user even if they'd never care to use it, so we just have to be very careful. If we get a LOT of requests for it, we very well may reconsider. And thanks for sharing the suggestion - we always like hearing from users about what they want. 

Link to post
Share on other sites

Yes, I see. I had thought that it was very common feature (Especially in real-time apps it is a must, isn't it?), because of that I was surprised. Thank you.

Link to post
Share on other sites

If it's a real-time app, couldn't you sync the progress of an animation based on the server time?

Link to post
Share on other sites

If it's a real-time app, couldn't you sync the progress of an animation based on the server time?

 

But occurs some thing like this:

 

- Server sends an information to x clients.

- Then clients will see a tween of 10 seconds.

- At the end of tween each client will send ACK to server.

- When server gets x ACK, then advances to next step.

- But meanwhile, when one client goes to other tab and returns, waiting for tween to be finished causes an unnecessary delay.

 

Of course, the role of server could be increased, but this way decreases the load of the server.

The server does not need every time synchronize the clients, except fundamental checkpoints.

In other words, the server assures that all clients are in the same state but does not bother how they view.

Link to post
Share on other sites

Ok. I see what you're doing. So how do you deal with latency and disconnects? It's pretty much the same thing going on. But ultimately there is only one thing you can do if you want an animation to continue playing. On a visibility change you're need to toggle between using frames and rAF.

// On hidden
TweenMax.ticker.useRAF(false);

// On visible
TweenMax.ticker.useRAF(true);

There is one caveat though, and it's not related to GSAP. When you switch to frames it's only going to run at 1fps. There's nothing GSAP can do about that because it's an optimization done by the browser. If 1 second is too long of delay and you need more accuracy, you're going to have to hijack the setTimeout method before loading GSAP and run it a web worker.

  • Like 1
Link to post
Share on other sites

In my case timing is not too restricted, because of that the server is rather relaxed.

I appreciate your suggestion. Thank you.

Link to post
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.

×