vue-lottie-web

a vue component for lottie-web
25,649 9
Install
npm install vue-lottie-web
Latest Version:0.0.3
Vue:2
License:MIT
Last Updated:May 17, 2019
Links: GitHub  ·  npm
Maintainer: hiyingfeng

vue-lottie-web

a vue component for lottie-web

Demo Show

show Demo in local:

git clone git@github.com:niyingfeng/vue-lottie-web.git

npm install

npm run dev

Component use

Install through npm:

npm install --save vue-lottie-web
# use component
<template>
    <div id="app">
        <p class="pBtn">
            <span @click="lottiePlay">开始</span>
            <span @click="lottieRePlay">再一次</span>
            <span @click="lottiePause">暂停</span>
            <span @click="lottieStop">停止</span>
        </p>
        <Lottie
            className="animation"
            renderer="canvas"
            :loop="false"
            :autoplay="false"
            :animationData=lottieData

            @getLottieInstance=getLottieInstance
            @onEnterFrame=onEnterFrame
            @onComplete=onComplete
            @onLoopComplete=onLoopComplete
        />
    </div>
</template>

<script>
import Lottie from 'vue-lottie-web';
import lottieData from './data.json';

export default {
    components: {
        Lottie
    },
    data() {
        return {
            lottieData,
            lottieInstance: ''
        };
    },

    methods: {
        getLottieInstance(lottieInstance) {
            this.lottieInstance = lottieInstance;

            console.log(lottieInstance)
        },
        lottiePlay() {
            this.lottieInstance && this.lottieInstance.play();
        },
        lottieRePlay() {
            this.lottieInstance && this.lottieInstance.stop();
            setTimeout(() => {
                this.lottieInstance.play();
            });
        },
        lottiePause() {
            this.lottieInstance && this.lottieInstance.pause();
        },
        lottieStop() {
            this.lottieInstance && this.lottieInstance.stop();
        },
        onComplete(e) {
            console.log('onComplete', e);
        },
        onLoopComplete(e) {
            console.log('onLoopComplete', e);
        },
        onEnterFrame(e) {
            // console.log('onEnterFrame', e);
        }
    }
};
</script>


Related Packages

vue3-lottie

Add Lottie animations to your Vue 3 or Nuxt 3 application.

4,548,239 427
blottie

Lottie component for VueJS 3 / Nuxt 3

6,365 14
@lottiefiles/vue-lottie-player

Lottie player wrapper for Vue.js by LottieFiles

209,675 121
vue-lottie

Lottie Animation View for Vue

416,933 1,313

Version History

Version Released Vue License
0.0.3 ^2.5.11 MIT
0.0.2 ^2.5.11 MIT