0

I have a lottie animation playing one time. When it completes playing I want to fade it out.

What is the best way to do it?

I am trying to fade in and out SVG lottie animations.

var params = {
    container: document.getElementById('lottie'),
    renderer: 'svg',
    loop: false,
    autoplay: false,
    animationData: animationData
};

var anim;
anim = lottie.loadAnimation(params);
 anim.addEventListener('DOMLoaded',function() {
        anim.play();
});

anim.addEventListener('complete',function() {
        //anim.destroy();
        // fade out code...
});
41 72 6c
  • 1,600
  • 5
  • 19
  • 30
Wisp Ever
  • 35
  • 6

2 Answers2

0

Try this code to fade out element on complete animation

    anim.onComplete = function (e) {
        // fade out code...
    }

Here's a codepen example:

https://codepen.io/jaredstanley/pen/NmQYQY

jared
  • 652
  • 9
  • 19
Vkuter
  • 247
  • 1
  • 7
0
anim.onComplete = function(){
  //
}

Here's a codepen with a working example(scroll down to the btm of the js panel) https://codepen.io/jaredstanley/pen/NmQYQY

jared
  • 652
  • 9
  • 19