Animation Controller interface

This interface is used to control animations. It provides methods to start, stop, pause, and restore animations. It also provides a way to wait for the animation to stop.

This interface extends the IEventEmitter interface, which means you can listen to these events emitted by the animation controller:

  • animating - Emitted when the animation finishes it's delay phase and starts animating.
  • stopped - Emitted when the animation stops either by calling the stop() method or when the animation finishes naturally.
interface IAnimationController {
    state: AnimationControllerState;
    emit<K>(event: Extract<K, string>, data: unknown): void;
    off<K>(event: Extract<K, string>, listener: {
        [s: string]: ((target: any, data: any) => void);
    }[K]): void;
    on<K>(event: Extract<K, string>, listener: {
        [s: string]: ((target: any, data: any) => void);
    }[K]): void;
    once<K>(event: Extract<K, string>, listener: {
        [s: string]: ((target: any, data: any) => void);
    }[K]): void;
    pause(): IAnimationController;
    restore(): IAnimationController;
    start(): IAnimationController;
    stop(): IAnimationController;
    waitUntilStopped(): Promise<void>;
}

Hierarchy

  • IEventEmitter
    • IAnimationController

Properties

Current state of the animation

  • stopped - The animation is currently stopped (at the beggining or end of the animation)
  • running - The animation is currently running
  • paused - The animation is currently paused

Methods

  • Type Parameters

    • K extends string | number

    Parameters

    • event: Extract<K, string>
    • data: unknown

    Returns void

  • Type Parameters

    • K extends string | number

    Parameters

    • event: Extract<K, string>
    • listener: {
          [s: string]: ((target: any, data: any) => void);
      }[K]

    Returns void

  • Type Parameters

    • K extends string | number

    Parameters

    • event: Extract<K, string>
    • listener: {
          [s: string]: ((target: any, data: any) => void);
      }[K]

    Returns void

  • Type Parameters

    • K extends string | number

    Parameters

    • event: Extract<K, string>
    • listener: {
          [s: string]: ((target: any, data: any) => void);
      }[K]

    Returns void

  • Promise that resolves when the last active animation is stopped (including when the animation finishes naturally).

    Returns Promise<void>

    The Promise returned by this method is reset every time the animation enters a new start/stop cycle. This means you must call start() before calling this method if you want to wait for the animation to stop.

    This method always returns a resolved promise if the animation is currently in a stopped state.