Search code examples
javascriptlottie

How do I use Lottie's onSegmentStart event handler?


In Lottie, what does the onSegmentStart event handler do? I can't find any documentation on it or how to use it. I would like to find a way to change setSpeed once a certain segment has been reached in the animation.


Solution

  • You should be able to do something like this

    const animation = lottie.loadAnimation({
      container: '#container',
      renderer: 'svg',
      loop: true,
      autoplay: true,
      ...
    })
    
    animation.onSegmentStart = function() {
      //change your setSpeed here
    }