Skip to content

Couldn't find onAnimationRepeat listener? #1851

Answered by calda
ArtemMikhaylov asked this question in Q&A
Discussion options

You must be logged in to vote

We don't currently provide callbacks for this type of thing. One key obstacle is that this wouldn't work with the new default Core Animation rendering engine, where Lottie itself isn't running code every frame so wouldn't know when to call the closure.

One way to accomplish this functionality in user code could be:

func playAnimationOnce() {
  animationView.play(loopMode: .playOnce, completion: {
    // perform code now that the animation has finished its loop
    self.playAnimationOnce() // continue looping after the animation completes
  })
}

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by ArtemMikhaylov
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #1850 on December 13, 2022 14:24.