Class Marquee

A custom marquee component that smoothly scrolls its child elements.

This component is designed to loop elements horizontally within a container, with support for customization such as speed, gap, pause on hover, and more.

Documentation

Hierarchy (View Summary)

Constructors

  • Parameters

    • Optionalprops: IMarqueeStaticProps & IMarqueeMutableProps & Partial<
          {
              onDestroy: (data: undefined, ctx: Marquee) => void;
              onProps: (data: Partial, ctx: Marquee) => void;
              onRender: (data: undefined, ctx: Marquee) => void;
              onResize: (data: undefined, ctx: Marquee) => void;
          },
      >
    • OptionalonCallbacks: Partial<
          {
              onDestroy: (data: undefined, ctx: Marquee) => void;
              onProps: (data: Partial, ctx: Marquee) => void;
              onRender: (data: undefined, ctx: Marquee) => void;
              onResize: (data: undefined, ctx: Marquee) => void;
          },
      >

    Returns Marquee

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.

  • Get default mutable properties.

    Returns {
        __mutableProp: true;
        adjustSpeed: boolean;
        centered: boolean;
        enabled: boolean;
        gap: string | number;
        pauseOnHover: boolean;
        pauseOnOut: boolean;
        speed: string | number;
    }

    • __mutableProp: true
    • adjustSpeed: boolean

      When need to use dynamic FPS factor to adjust the speed of the marquee.

      true
      
    • centered: boolean

      Centers the marquee content within the container.

      false
      
    • enabled: boolean

      Enables or disables the marquee animation. When false, the marquee will be paused.

      true
      
    • gap: string | number

      The gap between the marquee elements. Supports css units like px, rem, vw, vh, svh.

      0
      
    • pauseOnHover: boolean

      Pauses the marquee when the mouse hovers over it.

      false
      
    • pauseOnOut: boolean

      Pauses the marquee when the element leaves the viewport.

      true
      
    • speed: string | number

      The speed of the marquee animation. Supports css units like px, rem, vw, vh, svh.

      1
      
  • Get default static properties.

    Returns {
        __staticProp: true;
        cloneNodes: boolean;
        container: HTMLElement;
        direction: "horizontal" | "vertical";
        hasWillChange: boolean;
        resizeDebounce: number;
    }

    • __staticProp: true
    • cloneNodes: boolean

      Indicates whether to clone the marquee nodes. Can be set to false if DOM cloning is not preferred.

      true
      
    • container: HTMLElement

      The container element that holds the marquee content.

    • direction: "horizontal" | "vertical"

      Indicates the direction of the marquee animation.

      'horizontal'
      
    • hasWillChange: boolean

      Determines whether to apply the will-change CSS property to the marquee elements to optimize rendering. Setting this to true may improve performance.

      true
      
    • resizeDebounce: number

      The debounce delay for the resize event in milliseconds.

      0
      
  • Adds a callback on the module's destruction.

    Parameters

    • action: () => void

      The function to execute during destruction.

    Returns void