bounce.js使用

<template>
    <div class="chapter-4">
        <div class="bounce-box" ref="bounce_box"></div>
        <div class="btn_container">
             <el-button type="primary" @click="scale()" round>scale</el-button>
             <el-button type="primary" @click="rotate()" round>rotate</el-button>
             <el-button type="primary" @click="translate()" round>translate</el-button>
             <el-button type="primary" @click="skew()" round>skew</el-button>
             <el-button type="primary" @click="full()" round>full</el-button>
        </div>
    </div>
</template>

<script>
/* eslint-disable */
export default {
  mounted () {    
  },
  methods:{
      scale(){
        var bounce = new Bounce();
        console.log(bounce)
        bounce.scale({
        from: { x: 0.5, y: 0.5 },
        to: { x: 1, y: 1 }
        })
        bounce.applyTo(this.$refs.bounce_box)
      },
      rotate(){
        var bounce = new Bounce();
        // var saver=this.face
        // this.face=this.back
        this.back=saver
        bounce.rotate({
        from: 0,
        to: 180
        });
        bounce.applyTo(this.$refs.bounce_box)
      },
      translate(){
        var bounce = new Bounce();
        bounce.translate({
        from: { x: 0, y: 0 },
        to: { x: 100, y: 0 }
        });
        bounce.applyTo(this.$refs.bounce_box)
      },
      skew(){
        var bounce = new Bounce();
        bounce.skew({
        from: { x: 0, y: 0 },
        to: { x: 20, y: 0 }
        });
        bounce.applyTo(this.$refs.bounce_box)
      },
      full(){
            var bounce = new Bounce();
            bounce
            .translate({
                from: { x: -300, y: 0 },
                to: { x: 0, y: 0 },
                duration: 600,
                stiffness: 4
            })
            .scale({
                from: { x: 1, y: 1 },
                to: { x: 0.1, y: 2.3 },
                easing: "sway",
                duration: 800,
                delay: 65,
                stiffness: 2
            })
            .scale({
                from: { x: 1, y: 1},
                to: { x: 5, y: 1 },
                easing: "sway",
                duration: 300,
                delay: 30,
            })
            .applyTo(document.querySelectorAll(".bounce-box"))
            }
  },
  data(){
      return {
          bounce:null,
          face:0,
          back:180
      }
  }
}
</script>

<style scoped lang="scss">
.chapter-4{
    width: 100%;
    height: 100%;
    position:relative;
    display:flex;
    justify-content:center;
    align-items:center;
    .bounce-box{
        width: 150px;
        height: 150px;
        margin:0  auto;
        background-color: red;
        border-bottom: 5px solid green;
        animation: my-animation 1s linear both;
    }
    .btn_container{
        position: absolute;
        bottom:0;
        left: 0;
    }
}
</style>
  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值