Lottie-web: How to freeze the last frame in animation after it's done playing?

Created on 29 Jan 2018  路  9Comments  路  Source: airbnb/lottie-web

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!

Most helpful comment

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

All 9 comments

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.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

hardy613 picture hardy613  路  4Comments

processprocess picture processprocess  路  3Comments

DannyK123456 picture DannyK123456  路  3Comments

cpdt picture cpdt  路  4Comments

dulllud picture dulllud  路  3Comments