Created
November 19, 2019 08:41
-
-
Save itanka9/19f5b8e2685333957629f9f8f56d246a to your computer and use it in GitHub Desktop.
Lottie play(from, to).js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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