Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

198
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!