Class Timeline<CallbacksMap, StaticProps, MutableProps>

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

Documentation

Type Parameters

Hierarchy (View Summary)

Constructors

Properties

_callbacks: Callbacks<CallbacksMap>

Callbacks instance

_destroyable: () => void[] = []

Stores actions that need to be executed when the module is destroyed

_eased: number

Current eased progress of the timeline (after applying easing function).

_isDestroyed: boolean = false

Tracks whether the module has been destroyed

_isPaused: boolean

Indicates whether the timeline is paused.

_isReversed: boolean

Indicates whether the timeline is currently reversed.

_progress: number

Current linear progress of the timeline (0 to 1).

_props: TTRequiredProps<MutableProps & StaticProps>

Current properties

_raf?: number

Stores the ID of the current animation frame request.

_time: number

Stores the timestamp of the last frame update.

Accessors

  • get isDestroyed(): boolean

    Checks if the module has been destroyed.

    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

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.

  • Adds a callback on the module's destruction.

    Parameters

    • action: () => void

      The function to execute during destruction.

    Returns void

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

    Returns void

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

    Returns void