main.js中引入
import Velocity from 'velocity-animate'
Vue.prototype.Velocity = Velocity
实现序列动画
一般实现
<div class="demoBox" ref="demoBox"></div>
<div class="demoBox" ref="demoBox2"></div>
<div class="demoBox" ref="demoBox3"></div>
<button style="marginLeft:300px" @click="demoFunc">点我</button>
demoFunc(){
this.Velocity(this.$refs.demoBox,{width:'400px'},{duration:1000,complete:()=>{
this.Velocity(this.$refs.demoBox2,{width:'400px'},{duration:1000,complete:()=>{
this.Velocity(this.$refs.demoBox3,{width:'400px'},{duration:1000})
}})
}})
},
.demoBox{
width:100px;
height:100px;
background-color: pink;
}
序列动画
demoFunc() {
var seq = [
{
elements: this.$refs.demoBox,
properties: { width: "400px" },
options: { duration: 1000 }
},
{
elements: this.$refs.demoBox2,
properties: { width: "400px" },
options: { duration: 1000 }
},
{
elements: this.$refs.demoBox3,
properties: { width: "400px" },
options: { duration: 1000 }
}
];
this.Velocity.RunSequence(seq)
}
其他信息
jianshu.com/p/d81a9f0f11ea
https://zhuanlan.zhihu.com/p/107840853
https://www.jsopy.com/2019/12/26/vuecha8/
http://velocityjs.org/#beginAndComplete
http://shouce.jb51.net/velocity/feature.html
https://www.imooc.com/video/9156