Skip to content

Instantly share code, notes, and snippets.

@mrdoob
Created March 26, 2013 12:45
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