Pausing Javascript animation on minimize

👍:0

document.addEventListener("visibilitychange", function() {
  animation = ! document.hidden;
}, false);

https://developer.mozilla.org/en-US/docs/Web/Guide/User_experience/Using_the_Page_Visibility_API
Works in IE 10+, Firefox 18+ and Chrome 33+ (according to source).
You’ll have to change the animation = !document.hidden; yourself as you were a bit vague on this topic, but this should give you an idea.

Leave a comment