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

197
Vistas
Lottie how to run arbritary code inbetween two segments?

Let's say I've defined a lottie animation using var anim = bodymovin.loadAnimation({<anim data here>})

Now, what i wanna do is something like:

anim.playSegments([80,101]);
console.log("example");
anim.playSegments([102,121]);

The problem here is that console.log is not waiting for the first segment to end in order to run. It runs as soon as the first segment starts.

I understand this due to javascript being synchronous, but is there a way to run this asynchronously? In other words, is there a way for the console.log to wait for the first segment to finish before running?
Play segment -> do something -> play another segment


Things that I've tried:

anim.playSegments([80,101]).then(() => {
    console.log("test")
});
anim.playSegments([102,121]);

didn't work. Returns Uncaught TypeError: Cannot read properties of undefined (reading 'then')

 anim.playSegments([80,101])
 anim.onComplete = function() {
     console.log("Test")
 }
 anim.playSegments([102,121]);

This will run the console.log() after the second segment is complete.

anim.playSegments([80,101])
anim.onComplete = function() {
    console.log("frame!");
    anim.playSegments([102,121]);
}

this will keep looping the second segment, since it plays it again once it's complete.

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