vue中使用gsap的动画插件
乔文飞 Lv8

gsap 动画

TweenMax基础案例

  • npm install / yarn add 二选一

    1
    2
    npm install gsap --save
    yarn add gsap
  • component.vue局部引入,哪里需要哪里搬

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    <template>
    <div>
    <div id="demo">
    <p>以下例子每个动画的开始时间按0.5s 错开。TweenLite没有stagger。</p>
    <div class="box green"></div>
    <div class="box grey"></div>
    <div class="box orange"></div>
    <div class="box green"></div>
    <div class="box grey"></div>
    <div class="box orange"></div>
    <div class="box green"></div>
    <div class="box grey"></div>
    <div class="box orange"></div>
    </div>
    <el-button @click="showTest()">开始</el-button>
    </div>
    <template>
    <script>
    import { TweenLite, TweenMax } from 'gsap'
    export default {
    methods: {
    showTest: function(){
    //TweenMax、TimelineLite、TimelineMax可以使用stagger(错开动画),TweenLite则没有。
    TweenMax.staggerTo(".box", 1, {rotation:360, y:100}, 0.5);
    }
    }
    };
    </script>
  • 本文标题:vue中使用gsap的动画插件
  • 本文作者:乔文飞
  • 创建时间:2020-08-07 11:01:26
  • 本文链接:http://www.feidom.com/2020/08/07/vue中使用tweenmax动画插件/
  • 版权声明:本博客所有文章为作者学习笔记,有转载其他前端大佬的文章。转载时请注明出处。