I have an animation and on complete fuction, I want to fade it out or scale it out.
What is the best way to do it? I have seen some suggestions with barba.js, is that my only option?
*I will fade in as well before I anim.play
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() {
// fade out code...
setTimeout(function(){
anim.destroy();
}, 2000);
});
if you are using fading animations you can add / remove a class to your container element and animate it via css changing the opacity value and setting the transition property to something like:
transition: opacity 500ms ease-out