在Web Animation API中,我们可以通过Element.animate接口对元素进行动画处理。返回的Animation对象可以通过 、和进行播放、暂停或.play()
反转。.pause()
.reverse()
let img = document.querySelector('#happy-boy');
const boy_animation = [
{ transform: 'rotate(0)' },
{ transform: 'rotate(360deg)' },
];
const boy_timing = {
duration: 3000,
iterations: Infinity,
}
let animation = img.animate(boy_animation, boy_timing);
animation.reverse(); // <-- fails with DOM exception
当我尝试反转()动画时出现此错误:
Cannot play reversed Animation with infinite target effect end.
慕容森
相关分类