Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

201
Vistas
How to initially render the last frame of a lottie animation?

I would lottie2 to start at the end of the animation when loaded. Instead, it starts on the first frame, the first click doesn't affect anything, and then it works normal.

const lottie1 = document.querySelector('.lottie1');
let direction1 = 1;
lottie1.setDirection(direction1);
lottie1.addEventListener('click', () => {
  lottie1.setDirection(direction1);
  direction1 = direction1 === 1 ? -1 : 1;
  lottie1.play();
});

const lottie2 = document.querySelector('.lottie2');
let direction2 = -1;
lottie2.setDirection(direction2);
lottie2.addEventListener('click', () => {
  lottie2.setDirection(direction2);
  direction2 = direction2 === 1 ? -1 : 1;
  lottie2.play();
});
.lottie1, .lottie2 {
  cursor: pointer;
}
<script src="https://unpkg.com/@lottiefiles/lottie-player@0.4.0/dist/lottie-player.js"></script>

<h2>Works fine</h2>
<lottie-player
  class="lottie1"
  mode="normal"
  src="https://assets10.lottiefiles.com/packages/lf20_cgtqwvja.json"
  style="width: 50px">
</lottie-player>

<h2>Doesnt work - should start filled</h2>

<lottie-player
  class="lottie2"
  mode="normal"
  src="https://assets10.lottiefiles.com/packages/lf20_cgtqwvja.json"
  style="width: 50px">
</lottie-player>

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda