3

I can add animations to anime timeline using the timeline.add({parameters}) function. Is it possible to remove all the previously added animations and reset the whole timeline?

Thanks,

toddash
  • 167
  • 2
  • 17

1 Answers1

1

You can reset the timeline by calling the restart method:

const tl = anime.timeline({
  duration: 400,
  easing: 'easeInOutQuad',
})

tl.add({
  targets: '.box',
  rotate: 360,
  translateX: {
    value: 400,
    delay: 400,
  }
})

document.querySelector('button').addEventListener('click', () => {
    tl.restart();
});
Adrian Mole
  • 49,934
  • 160
  • 51
  • 83