zoukankan      html  css  js  c++  java
  • Vue过渡:用Velocity实现JavaScript钩子

    Velocity is an animation engine with a similar API to jQuery's $.animate(). It has no dependencies, but will happily extend jQuery, Zepto, and even the native DOM. It's incredibly fast, and it features color animation, transforms, loops, easings, SVG support, and scrolling.

    一 安装依赖

    npm install velocity-animate  (这里是1.5.2版本)

    文档地址:https://github.com/julianshapiro/velocity/wiki

    二 App.vue

    <!-- App.vue -->
    <template>
      <div id="app">
        <button @click="show = !show">按钮</button>
        <transition 
          @before-enter="beforeEnter"
          @enter="enter"
          @leave="leave"
          :css="false"
        >
          <p v-if="show">芒果</p>
        </transition>
      </div>
    </template>
    
    <script>
    import Vue from "vue";
    import Velocity from "velocity-animate";
    
    export default {
      name: "app",
      data() {
        return {
          show: false
        };
      },
      methods: {
        beforeEnter(el) {
          el.style.opacity = 0;
          el.style.transformOrigin = "left";
        },
        enter(el, done) {
          // 动画队列
          Velocity(el, { opacity: 1, scale: 1.2 }, { duration: 300 });
          Velocity(el, { scale: 1 }, { complete: done });
        },
        leave(el, done) {
          // 动画队列
          Velocity(el, { translateX: "15px", rotateZ: "50deg" }, { duration: 600 });
          Velocity(el, { rotateZ: "100deg" }, { loop: 2 });
          Velocity(
            el,
            {
              rotateZ: "45deg",
              translateY: "30px",
              translateX: "30px",
              opacity: 0
            },
            { complete: done }
          );
        }
      }
    };
    </script>
    
    <style>
    </style>

    三 运行效果

  • 相关阅读:
    UVa 11181
    UVa 10491
    UVa 1636
    UVa 1262
    UVa 10820
    UVa 1635
    UVa 12716
    [2019杭电多校第六场][hdu6635]Nonsense Time
    [2019杭电多校第五场][hdu6630]permutation 2
    [2019杭电多校第五场][hdu6629]string matching(扩展kmp)
  • 原文地址:https://www.cnblogs.com/sea-breeze/p/11310111.html
Copyright © 2011-2022 走看看