- 项目里接触到这个库,在这里记录一下。
- 使用JavaScript在浏览器中动态生成CSS关键帧动画。
- 可以在项目中npm下载
var animations = require('create-keyframe-animation')
enter(el, done) {
let animation = {
0: {
transform: `translate3d(${x}px, ${y}px, 0) scale(${scale})`
},
60: {
transform: 'translate3d(0, 0, 0) scale(1.2)'
},
100: {
transform: 'translate3d(0, 0, 0) scale(1)'
}
}
animations.registerAnimation({
name: 'move',
animation,
presets: {
duration: 1000,
easing: 'linear',
delay: 500
terations: 1,
delay: 0,
direction: ‘normal‘,
resetWhenDone: false,
clearTransformsBeforeStart: false
}
})
animations.runAnimation(el, 'move', function () {
})
},
afterEnter() {
animations.unregisterAnimation('move')
this.$refs.cdWrapper.style.animation = ''
}