I am loving the lottie plugin so far. However, the animation disappears after it plays out. How can i freeze it at the last frame when it's done playing? Thanks in advance!
hey rajthakkar77,
i used this javascript snippet ;)
var container = document.getElementById("logo"),
anim = lottie.loadAnimation({
container: container,
renderer: "svg",
loop: false,
autoplay: true,
path: "static/logo.08.json"
});
anim.addEventListener("enterFrame", function (animation) {
if (animation.currentTime > (anim.totalFrames - 1)) {
anim.pause();
}
});
you must stop manually at the last frame!
cheers
Hi @dutscher
Thanks a lot! Works like magic 馃挴
Hi, this has been fixed on the player side too on version 5.1.7, so no need to do this workaround anymore
Hi, I'm still seeing this issue with the web player. Is this fixed?
@mlaurita can you share an example?
Sure!
<script src="https://unpkg.com/@lottiefiles/lottie-player@latest/dist/lottie-player.js"></script>
<lottie-player
src="https://assets2.lottiefiles.com/packages/lf20_BYtDqx.json" background="#00A9DA" speed="1" style="width: 300px; height: 300px;" autoplay >
</lottie-player>
@bodymovin any news?
@mlaurita I'm not the maintainer of the lottie-player by lottiefiles, but someone already asked me about this before.
Apparently they are resetting the play position of the animation once it is finished, no idea why, I suggest that you open an issue on their repository.
Edit:
it seems the issue is already open
https://github.com/LottieFiles/lottie-player/issues/2
Hello, I'm very new to code
So far my issue is I want pause at a frame for few seconds and then continue playing the animation.
There are three pause-and-play I want to insert on to my animation. Thanks for your work and support. This plugin is phenomenal.
Most helpful comment
hey rajthakkar77,
i used this javascript snippet ;)
you must stop manually at the last frame!
cheers