Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Restarting logic causes slow animations to be stuck forever #294

Open
jstcki opened this issue Mar 2, 2016 · 2 comments
Open

Restarting logic causes slow animations to be stuck forever #294

jstcki opened this issue Mar 2, 2016 · 2 comments

Comments

@jstcki
Copy link

jstcki commented Mar 2, 2016

Sometimes animations with a low frame rate seem to get stuck forever, jumping back and forth. Here's a demo case: http://bl.ocks.org/herrstucki/cf4978db089df7b25262

I traced it to this bit of code:

// more than 10 frames? prolly switched browser tab. Restart
if (this.accumulatedTime > msPerFrame * 10) {
  this.accumulatedTime = 0;
}

https://github.com/chenglou/react-motion/blob/master/src/TransitionMotion.js#L368-L371

When I remove it, the problem goes away. I'm not too familiar with the RM code, so I can't really say if this is an essential piece. In any case, the 10 frames heuristic seems a bit too strict (I know that 6 FPS isn't really acceptable but you don't always know the performance of the user's machine). And shouldn't the animation just resume or skip to the end instead?

@chenglou
Copy link
Owner

The discussion was here. Would increasing that limit work out for you? Say, to 15?

@jstcki
Copy link
Author

jstcki commented Apr 20, 2016

I don't think arbitrarily changing the limit helps. The solution may be to instead of resetting accumulatedTime to 0 (and thus triggering this.startAnimationIfNecessary()) to cap it to msPerFrame * 10. So:

// more than 10 frames? prolly switched browser tab. Restart
if (this.accumulatedTime > msPerFrame * 10) {
  this.accumulatedTime = msPerFrame * 10;
}

But it's been a while since I reported this 😄 . I'd have to test that assumption first.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants