Whether to loop when reaching the end boundary.
When true, the source resets to position 0 and continues.
When false, the source emits 'end' boundary and deactivates.
For sources where looping is not applicable (e.g., mouse position), this property has no effect.
ReadonlystateCurrent state of the position source
Deactivate the position source and reset to initial state.
Transitions state to inactive.
Position is reset (typically to 0).
Destroy the position source and release all resources.
After calling destroy, the source cannot be reused. Removes event listeners, closes connections, clears timers.
Get the total duration.
Duration in seconds (or source-specific units), or Infinity for unbounded sources
Get the current position.
Current position in seconds (or source-specific units)
Register a callback for when the source becomes active.
Called once each time the source transitions to the active state.
This is equivalent to "first frame" semantics - for RAF sources it's
the first tick, for video sources it's when playback actually starts.
Function called when source becomes active
Register a callback for boundary events.
Called when position reaches a boundary (start or end).
For looping sources, 'end' is emitted before reset.
Function receiving the boundary type
Register a callback for position updates.
Called whenever the position changes while the source is active. Frequency depends on the source type (e.g., RAF tick, video timeupdate).
Function receiving the current position
Suspend the position source, preserving current position.
Transitions state from active to suspended.
Position updates stop but position is preserved for later resumption.
Core interface for timeline position sources.
A position source provides the current position within a timeline and emits position updates. The source of position can vary: elapsed time (RAF), media playback (video), scroll position, mouse position, external data, etc.
Example