chenqingspring / vue-lottie

Render After Effects animations on Vue based on Bodymovin
MIT License
1.31k stars 281 forks source link

Emit 'complete' event when an animation finishes #28

Open dylanbhughes opened 5 years ago

dylanbhughes commented 5 years ago

It would be helpful if a Lottie component emitted a complete event when the animation completed a loop

LavrovE commented 4 years ago

yeah

siba2893-avantica commented 4 years ago

Any progress on this?

xing00 commented 3 years ago

you can use addEventListener, just like:


<template>
            <Lottie :options="defaultOptions" @animCreated="handleAnimation"></Lottie>
</template>
<script>
export default {
     methods:{
         onAnimComplete() {
        // do something

         },
         handleAnimation(ami) {
              this.ami = ami
             this.ami.addEventListener('complete', this.onAnimComplete)
    },
     }
}
</script>
`

more events see this link: https://github.com/airbnb/lottie-web
tafhyseni commented 3 years ago

Try this out

<template>
    <lottie :options="defaultOptions" v-on:animCreated="handleAnimation" />
</template>

<script>
    export default {
        methods: {
            handleAnimation(anim) {
                this.anim = anim;
                this.anim.addEventListener('complete', () => this.animationCompleted());
            },
            animationCompleted() {
                alert('Loading Completed!');
            }
        }
    }
</script>

You can find more animation instances methods and events at AirBnb Lottie Web