Skip to content

Instantly share code, notes, and snippets.

@mrdoob
Created March 26, 2013 12:45
Show Gist options
  • Star 12 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mrdoob/5245098 to your computer and use it in GitHub Desktop.
Save mrdoob/5245098 to your computer and use it in GitHub Desktop.
Avoiding huge delta times when switching tabs.
// firefox
document.addEventListener( 'visibilitychange', function ( event ) {
if ( document.hidden === false ) {
lastTime = performance.now();
}
}, false );
// webkit
document.addEventListener( 'webkitvisibilitychange', function ( event ) {
if ( document.webkitHidden === false ) {
lastTime = performance.now();
}
}, false );
@mrdoob
Copy link
Author

mrdoob commented Mar 26, 2013

AKA "pausing the animation".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment