Create a new scroll-based position source.
Configuration options
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.
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.
Current 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.
ProtecteddoPerform source-specific cleanup.
Called by destroy(). Override to release resources, unbind listeners, etc.
ProtecteddoPerform source-specific initialization.
Called by init(). Override to load resources, bind listeners, etc.
ProtectedemitEmit a boundary event to all registered callbacks.
The boundary type ('start' or 'end')
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
Seek to a specific position by programmatically scrolling.
Target position in seconds (0 to duration)
Actual position after scroll
ProtectedsetSet the current position and emit to callbacks.
Only emits if the source is active.
New position value
ProtectedstartStart emitting position updates.
Called when transitioning to active state.
Override to start timers, begin listening to events, etc.
ProtectedstopStop emitting position updates.
Called when transitioning from active to suspended or inactive.
Override to stop timers, pause listening, etc.
Suspend the position source, preserving current position.
Transitions state from active to suspended.
Position updates stop but position is preserved for later resumption.
Scroll-based position source.
Maps scroll position to a timeline position. The position is calculated as a percentage of the scroll progress multiplied by the configured duration.
Implements
IPositionSourceandISeekable.Example