Velocity.js的使用

本文介绍了如何使用Velocity.js库在Vue应用中创建流畅的序列动画,通过实例演示了如何为多个<div>元素设置宽度动画,并提供了多种资源链接以供深入学习。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值