eligius
    Preparing search index...

    Class RafPositionSource

    RequestAnimationFrame-based position source.

    Uses the animationInterval utility to emit position updates at a regular interval (default: 1 second). Position increments by 1 per second, making position values equivalent to elapsed seconds.

    Implements both IPositionSource (via BasePositionSource) and ISeekable.

    const source = new RafPositionSource({ duration: 60 });
    await source.init();

    source.onPosition((position) => {
    console.log(`Position: ${position}s`);
    });

    source.onBoundaryReached((boundary) => {
    if (boundary === 'end') {
    console.log('Timeline complete');
    }
    });

    await source.activate();

    // Seek to 30 seconds
    await source.seek(30);

    Hierarchy (View Summary)

    Implements

    Index

    Constructors

    Accessors

    • get loop(): boolean

      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.

      Returns boolean

    • set loop(value: boolean): void

      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.

      Parameters

      • value: boolean

      Returns void

    Methods

    • 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.

      Parameters

      • callback: () => void

        Function called when source becomes active

      Returns void