简体   繁体   English

动漫 js - 重置整个时间线(删除所有以前添加的动画)

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

I can add animations to anime timeline using the timeline.add({parameters}) function.我可以使用timeline.add({parameters}) function 将动画添加到动画时间轴。 Is it possible to remove all the previously added animations and reset the whole timeline?是否可以删除所有先前添加的动画并重置整个时间线?

Thanks,谢谢,

You can reset the timeline by calling the restart method:您可以通过调用restart方法来重置时间线:

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();
});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM