Created
March 26, 2013 12:45
-
-
Save mrdoob/5245098 to your computer and use it in GitHub Desktop.
Avoiding huge delta times when switching tabs.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
AKA "pausing the animation".