Overview
The Timeline animation system provides a powerful way to create complex animations in OpenTUI. It supports property animations, easing functions, looping, callbacks, and nested timelines.Creating a Timeline
createTimeline()
Creates and registers a new timeline with the animation engine.Configuration options for the timeline
A new Timeline instance registered with the animation engine
Timeline Class
add()
Adds an animation to the timeline at a specific start time.The object or array of objects to animate. Can be any object with numeric properties.
Animation properties and options
When to start the animation in milliseconds from the timeline start
Returns the timeline instance for method chaining
once()
Adds a one-time animation that starts at the current timeline position and is automatically removed when complete.The object to animate
Animation properties (same as
add() method)Returns the timeline instance for method chaining
call()
Adds a callback function to be executed at a specific time in the timeline.Function to execute
When to execute the callback in milliseconds from the timeline start
Returns the timeline instance for method chaining
sync()
Synchronizes another timeline to start at a specific time in this timeline.The timeline to synchronize
When to start the synchronized timeline in milliseconds
Returns the timeline instance for method chaining
play()
Starts or resumes playback of the timeline.Returns the timeline instance for method chaining
pause()
Pauses playback of the timeline.Returns the timeline instance for method chaining
restart()
Restarts the timeline from the beginning.Returns the timeline instance for method chaining
update()
Manually updates the timeline by a delta time. This is typically called automatically by the animation engine.Time elapsed in milliseconds since last update
Timeline Properties
Current playback position in milliseconds
Whether the timeline is currently playing
Whether the timeline has completed playback
Total duration of the timeline in milliseconds
Whether the timeline loops
Timeline Engine
The global animation engine manages all timelines and integrates with the renderer.engine.attach()
Attaches the engine to a CLI renderer to synchronize with frame updates.The renderer to attach to
engine.register()
Manually registers a timeline with the engine.The timeline to register
engine.unregister()
Unregisters a timeline from the engine.The timeline to unregister
engine.clear()
Unregisters all timelines from the engine.JSAnimation Interface
The animation object passed toonUpdate callbacks.
Array of objects being animated
Current progress of the animation (0-1), after easing is applied
Current timeline time in milliseconds
Time elapsed since last frame in milliseconds