demo/index.js
function watchFocus() {
  var _blurred = false;
  window.addEventListener('focus', function() {
    if (_blurred) {
      _blurred = false;
      // startAnimating();
      // controls.freeze = false;
    }
  });
  window.addEventListener('blur', function() {
    // stopAnimating();
    _blurred = true;
    controls.freeze = true;
  });
}
function watchFocus() {
  var _blurred = false;
  window.addEventListener('focus', function() {
    if (_blurred) {
      _blurred = false;
      // startAnimating();
      // controls.freeze = false;
    }
  });
  window.addEventListener('blur', function() {
    // stopAnimating();
    _blurred = true;
    controls.freeze = true;
  });
}
function watchFocus ( ) { var _blurred = false ; window . addEventListener ( 'focus' , function ( ) { if ( _blurred ) { _blurred = false ; // startAnimating(); // controls.freeze = false; } } ) ; window . addEventListener ( 'blur' , function ( ) { // stopAnimating(); _blurred = true ; controls . freeze = true ; } ) ; }
Stop animating if the window is out of focus
Stop animating if the window is out of focus