Skip to content

Instantly share code, notes, and snippets.

@itanka9
Created November 19, 2019 08:41
Show Gist options
  • Select an option

  • Save itanka9/19f5b8e2685333957629f9f8f56d246a to your computer and use it in GitHub Desktop.

Select an option

Save itanka9/19f5b8e2685333957629f9f8f56d246a to your computer and use it in GitHub Desktop.
Lottie play(from, to).js
play (from, to) {
if (from !== undefined) {
this.player.setCurrentRawFrameValue(from)
}
if (to) {
this.targetFrame = to
}
this.player.setDirection(from < to ? 1 : -1)
this.player.play()
}
this.player.addEventListener('enterFrame', () => {
const currentFrame = Math.trunc(this.player.currentFrame)
if (currentFrame === this.targetFrame) {
this.player.pause()
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment