AbstractCreate a new position source.
Total duration in seconds (or Infinity for unbounded)
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.
Protected AbstractdoPerform source-specific cleanup.
Called by destroy(). Override to release resources, unbind listeners, etc.
Protected AbstractdoPerform 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
ProtectedsetSet the current position and emit to callbacks.
Only emits if the source is active.
New position value
Protected AbstractstartStart emitting position updates.
Called when transitioning to active state.
Override to start timers, begin listening to events, etc.
Protected AbstractstopStop 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.
Abstract base class for position sources.
Provides shared state management, lifecycle handling, and callback registration for concrete position source implementations.
Subclasses must implement:
doInit()- Source-specific initializationdoDestroy()- Source-specific cleanupstartTicking()- Start emitting position updatesstopTicking()- Stop emitting position updatesExample