Google News
logo
Anime.js - Interview Questions
What is the Suspend on Visibility Change in Anime.js?
anime.suspendWhenDocumentHidden = false; // default true
By default all animations are paused when switching tabs, useful if you want to make sure the user sees everything and doesn't miss an important part of your animation.

But you can choose to let the animation runs normally without any pause, like a video or an audio track that can continuously plays in the background.
 
Example : 
var visibilitychangeLogEl = document.querySelector('.visibilitychange-log');

anime({
  targets: '.visibilitychange-demo .el',
  translateX: 270,
  direction: 'alternate',
  easing: 'easeInOutQuad',
  loop: true,
  duration: 2000,
  update: function(a) {
    visibilitychangeLogEl.innerHTML = 'animation progress ' + Math.round(a.progress);
  }
});
Advertisement