Methods
note
All Module methods are available in this class.
pause
Pause the timeline, halting progress without resetting it.
Emits the pause callback when a rAF loop is active.
const tm = new Timeline();
tm.pause();
play
Plays forward toward progress = 1.
Notes:
- If the timeline is reversed, calling
play()switches it to forward mode. - Emits
resumewhen resuming from a pause, thenplay. - No-op when progress is already
1or the instance is destroyed.
const tm = new Timeline();
tm.play();
reset
Reset the timeline to the beginning (progress = 0).
Emits reset before progress is set to 0 (start follows from the progress change).
const tm = new Timeline();
tm.reset();
reverse
Reverse the timeline, moving progress from the current value toward 0.
Notes:
- If the timeline is playing forward, calling
reverse()switches direction. - Emits
resumewhen resuming from a pause, thenreverse. - Does nothing if progress is already
0or the instance is destroyed.
const tm = new Timeline();
tm.reverse();
destroy
Destroys the instance and cleans up resources.
const tm = new Timeline();
tm.destroy();