zoukankan      html  css  js  c++  java
  • Vue中的Js动画与Velocity.js 的结合

    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>Vue中的Js动画与Velocity.js的结合</title>
        <script src="./vue.js"></script>
        <script src="./velocity.min.js"></script>
    </head>
    <body>
    <div id="root">
        <transition name="fade"
                    @before-enter="handleBeforeEnter"
                    @enter="handleEnter"
                    @after-enter="handleAfterEnter">
            <div v-show="show">hello world</div>
        </transition>
        <button @click="handleClick">toggle</button>
    </div>
    <script>
    
        var vm = new Vue({
            el: '#root',
            data: {
                show: true
            },
            methods: {
            handleClick: 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>
    </body>
    </html>
    
    <!--
    入场动画钩子函数:@before-enter @enter @after-enter
    出场动画钩子函数:@before-leave @leave @after-leave
    velocity.min.js是js动画库
    -->
    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>Vue中的Js动画与Velocity.js的结合</title>
        <script src="./vue.js"></script>
        <script src="./velocity.min.js"></script>
    </head>
    <body>
    <div id="root">
        <transition name="fade"
                    @before-enter="handleBeforeEnter"
                    @enter="handleEnter"
                    @after-enter="handleAfterEnter">
            <div v-show="show">hello world</div>
        </transition>
        <button @click="handleClick">toggle</button>
    </div>
    <script>
    
        var vm = new Vue({
            el: '#root',
            data: {
                show: true
            },
            methods: {
            handleClick: 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>
    </body>
    </html>
    
    <!--
    入场动画钩子函数:@before-enter @enter @after-enter
    出场动画钩子函数:@before-leave @leave @after-leave
    velocity.min.js是js动画库
    -->
  • 相关阅读:
    Fiddler抓包工具-拦截,断点
    python-zx笔记11-测试压力管理
    python-zx笔记10-断言
    python-zx笔记9-单元测试
    [Trouble shooting] Alt-A shortcut taken by another app and conflict with Emacs' M-a
    Dwango Programming Contest 6th Task C. Cookie Distribution
    局部有限偏序集上的 Möbius 函数
    一个求和
    一个组合问题
    ABC #150 E. Change a Little Bit
  • 原文地址:https://www.cnblogs.com/xuyxbiubiu/p/10020504.html
Copyright © 2011-2022 走看看