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

267
Views
Running Lottie animation within each loop, but wait for animations to complete?

I'm using [lottie-web][1] to play some SVG animations in the browser, but I need them to play one at a time, and only move onto the next once the current animation has completed.

At present, lottie.play() plays all the animations at once, where as I want to run them once at a time, before moving onto the next loop within each().

I feel like this should be relatively simple, but struggling to make it work. I've been playing with lottie.onComplete but with no luck so far. Perhaps I need to register each animation separately?

Thanks.

HTML

<div class="step one">
    <div class="animation" data-json="JSON DATA HERE"></div>
</div>
<div class="step two">
    <div class="animation" data-json="JSON DATA HERE"></div>
</div>
<div class="step three">
    <div class="animation" data-json="JSON DATA HERE"></div>
</div>

Script

// Vars
var steps = $('.step');

// Loop through steps
steps.each( function(){
      
    // Find animation for this step
    var animation = $(this).find('.animation');
    // Convert from jQuery to vanilla js for use with lottie-web
    var anim = animation.get(0);

    // Lottie animation (vanilla js)
    var lottie = bodymovin.loadAnimation({
        container: anim,
        renderer: 'svg',
        loop: false,
        autoplay: false, // Don't autoplay, so we can play at desired time
        path: anim.getAttribute('data-json')
    });

    // Play animation
    lottie.play(); // Plays all, but should only play current animation

    // On animation complete
    lottie.onComplete = function(){

      // On complete, proceed to next .step
      console.log('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!