Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Emit 'complete' event when an animation finishes #28

Open
dylanbhughes opened this issue Mar 14, 2019 · 4 comments
Open

Emit 'complete' event when an animation finishes #28

dylanbhughes opened this issue Mar 14, 2019 · 4 comments

Comments

@dylanbhughes
Copy link

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

@LavrovE
Copy link

LavrovE commented Dec 9, 2019

yeah

@siba2893-avantica
Copy link

Any progress on this?

@xing00
Copy link

xing00 commented Sep 24, 2020

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
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants