Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

anime js - reset entire timeline (remove all previously added animations)

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,

like image 558
toddash Avatar asked Dec 17 '25 11:12

toddash


1 Answers

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();
});
like image 168
SassCrafter Avatar answered Dec 19 '25 23:12

SassCrafter



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!