Google News
logo
Anime.js - Interview Questions
What are the begin() and complete() callbacks in Anime.js?
begin() callback is triggered once, when the animation starts playing.
 
complete() callback is triggered once, when the animation is completed.
 
Both begin() and complete() callbacks are called if the animation's duration is 0.

Type Parameters Info
Function animation Return the current animation Object

Example : 
anime({
  targets: '.begin-complete-demo .el',
  translateX: 240,
  delay: 1000,
  easing: 'easeInOutCirc',
  update: function(anim) {
    progressLogEl.value = 'progress : ' + Math.round(anim.progress) + '%';
    beginLogEl.value = 'began : ' + anim.began;
    completeLogEl.value = 'completed : ' + anim.completed;
  },
  begin: function(anim) {
    beginLogEl.value = 'began : ' + anim.began;
  },
  complete: function(anim) {
    completeLogEl.value = 'completed : ' + anim.completed;
  }
});
Advertisement