Class Preloader<CallbacksMap, StaticProps, MutableProps>

Page preloader component that manages the visibility and lifecycle of a loading screen. The module does not provide styling for the container.

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

_isDestroyed: boolean = false

Tracks whether the module has been destroyed

_isHidden: boolean = false

Indicates if the preloader has already been hidden.

_isLoaded: boolean = false

Indicates if the page is fully loaded.

_props: TTRequiredProps<MutableProps & StaticProps>

Current properties

_shouldHide: boolean = false

Indicates if the preloader is in the process of being hidden.

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.

  • Internal method to handle the destruction of the module. It removes all callbacks, destroys properties, and cleans up event listeners and class names.

    Returns void

  • Executes the hiding animation for the preloader container.

    Parameters

    • onHidden: () => void
    • duration: number

    Returns void

  • Handles the page load event, triggering when the page is fully loaded.

    Parameters

    • callback: () => void

    Returns void

  • Hides the preloader with a custom animation duration.

    Parameters

    • duration: number

      The duration of the hide animation (in milliseconds). Applies only when the container is used.

    • Optionalcallback: () => void

      The callback to execute when the hide animation is complete.

    Returns undefined | () => void

    Returns an action destructor.

  • Adds a callback on the module's destruction.

    Parameters

    • action: () => void

      The function to execute during destruction.

    Returns void

  • Registers a callback for when the preloader is fully hidden.

    Parameters

    • action: () => void

      The callback function to execute.

    Returns () => void

    A destructor.

  • Registers a callback for when the preloader starts hiding.

    Parameters

    • action: () => void

      The callback function to execute.

    Returns () => void

    A destructor.