Class Timeline

A timeline class for managing animations with easing and precise progress control. It provides methods for playing, reversing, pausing, and resetting the timeline.

Documentation

Hierarchy (View Summary)

Constructors

  • Parameters

    • Optionalprops: ITimelineStaticProps & ITimelineMutableProps & Partial<
          {
              onDestroy: (data: undefined, ctx: Timeline) => void;
              onEnd: (data: undefined, ctx: Timeline) => void;
              onProps: (data: Partial, ctx: Timeline) => void;
              onStart: (data: undefined, ctx: Timeline) => void;
              onUpdate: (data: ITimelineProgressArg, ctx: Timeline) => void;
          },
      >
    • OptionalonCallbacks: Partial<
          {
              onDestroy: (data: undefined, ctx: Timeline) => void;
              onEnd: (data: undefined, ctx: Timeline) => void;
              onProps: (data: Partial, ctx: Timeline) => void;
              onStart: (data: undefined, ctx: Timeline) => void;
              onUpdate: (data: ITimelineProgressArg, ctx: Timeline) => void;
          },
      >

    Returns Timeline

Accessors

  • get duration(): number

    Get the timeline duration, ensuring it is at least 0 ms.

    Returns number

  • get eased(): number

    Get the eased progress of the timeline, derived from the easing function.

    Returns number

  • get isDestroyed(): boolean

    Checks if the module has been destroyed.

    Returns boolean

  • get isPaused(): boolean

    Whether the timeline is paused.

    Returns boolean

  • get isPlaying(): boolean

    Whether the timeline is currently playing.

    Returns boolean

  • get isReversed(): boolean

    Whether the timeline is reversed (progress decreases over time).

    Returns boolean

  • get name(): string

    The name of the module, derived from the class name

    Returns string

  • get prefix(): string

    Optional prefix for classnames used by the module

    Returns string

  • get progress(): number

    Get or set the linear progress of the timeline. Setting this triggers an update and associated callbacks.

    Returns number

  • set progress(val: number): void

    Parameters

    • val: number

    Returns void

Methods

  • Adds a class name on an element, and keeps track of it for removal when the module is destroyed.

    Parameters

    • element: Element

      The target DOM element.

    • className: string

      The class name to toggle.

    Returns void

  • Helper function to generate classnames with the module's prefix.

    Parameters

    • ...classNames: string[]

      The class names to generate.

    Returns string

    A string of class names with the module's prefix applied.

  • Destroy the timeline, stopping any active animation and cleaning up resources.

    Returns void

  • Get default mutable properties.

    Returns {
        __mutableProp: true;
        duration: number;
        easing: false | number[] | TEasingFunction;
    }

    • __mutableProp: true
    • duration: number

      Timeline duration in milliseconds.

      1000
      
    • easing: false | number[] | TEasingFunction

      Easing function for timeline progression. Accepts standard easing types or an array of bezier values.

      false
      
  • Get default static properties.

    Returns { __staticProp: true }

  • Destroys the module, cleaning up resources, callbacks, and event listeners.

    Returns void

  • Adds a callback on the module's destruction.

    Parameters

    • action: () => void

      The function to execute during destruction.

    Returns void

  • Pause the timeline, halting progress without resetting it.

    Returns void

  • Play the timeline, advancing progress toward completion. Does nothing if the timeline is destroyed or already completed.

    Returns void

  • Reset the timeline to the beginning (progress = 0).

    Returns void

  • Reverse the timeline, moving progress toward the start. Does nothing if the timeline is destroyed or already at the start.

    Returns void