animaction,判断动画执行结束,js添加动画的@keyframes

var anim = document.querySelector('div')
anim.addEventListener('animationend',function(e){
    //动画执行完毕 执行
    console.log(e)//当前动画的属性
    console.log(e.animationName) //当前动画的名字;
})

 js添加动画的@keyframes

var style = document.styleSheets[0];
    style.insertRule('@keyframes anim_two{0%{ transform: translateX('+ window.innerWidth+'px); }100%{ transform: translate(-100%);}}');
    style.insertRule('@keyframes anim_three{0%{ transform: translateX('+ window.innerWidth+'px); }100%{ transform: translate(-100%);}}');

猜你喜欢

转载自blog.csdn.net/Cat_LIKE_Mouse/article/details/124258420