zoukankan      html  css  js  c++  java
  • vue的JS动画——动画钩子

    https://www.jianshu.com/p/55305c53de13

    transition动画钩子初识:

      <div id="root">
        <transition name='fade'
          @before-enter='handleBeforeEnter'
          @enter='handleEnter'
          @after-enter='handleAfterEnter'
        >
          <h1 v-show='show'>
            最是年少时模样
          </h1>
        </transition>
        <button @click='change'>切换</button>
      </div>
      <script>
        var vm=new Vue({
          el:'#root',
          data:{
            show:true
          },
          methods:{
            change:function(){
              this.show=!this.show;
            },
            handleBeforeEnter:function(el){
              console.log('before');
              el.style.color='red'
            },
            handleEnter:function(el,done){
              console.log('enter');
              setTimeout(()=>{
                el.style.color='green'
              },2000)
              setTimeout(()=>{
                done();
              },4000)
            },
            handleAfterEnter:function(el){
              console.log('after');
              el.style.color='#000000'
            }
          }
        })
      </script>

     使用velocity.js

      <div id="root">
        <transition name='fade'
          @before-enter='handleBeforeEnter'
          @enter='handleEnter'
          @after-enter='handleAfterEnter'
        >
          <h1 v-show='show'>
            最是年少时模样
          </h1>
        </transition>
        <button @click='change'>切换</button>
      </div>
      <script>
        var vm=new Vue({
          el:'#root',
          data:{
            show:true
          },
          methods:{
            change:function(){
              this.show=!this.show;
            },
            handleBeforeEnter:function(el){
              el.style.opacity=0;
            },
            handleEnter:function(el,done){
             Velocity(el,{opacity:1},{duration:1000,complete:done})
            },
            handleAfterEnter:function(el){
              console.log('动画结束');
            }
          }
        })
      </script>
  • 相关阅读:
    stm32ADC+DMA串口发送实验
    凑算式
    全排列
    字符串相同
    判断值相同
    插入加号求最小值
    动态规划递归—最小子段和
    动态规划-最小子段和
    进程的描述和进程的创建
    系统调用下
  • 原文地址:https://www.cnblogs.com/em2464/p/12337910.html
Copyright © 2011-2022 走看看