Class Scrollbar

A custom scrollbar component. Supports both window and HTMLElement containers.

Documentation

Hierarchy (View Summary)

Constructors

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 parent(): HTMLElement

    The element where the scrollbar is appended. If parent is not set, it defaults to container or document.body (if applied to window).

    Returns HTMLElement

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; autoSize: boolean; minSize: string | number }

    • __mutableProp: true
    • autoSize: boolean

      Enables automatic adjustment of the scrollbar size.

      true
      
    • minSize: string | number

      Minimum size of the scrollbar thumb. Accepts numeric values (interpreted as pixels) or CSS units (px, rem, vw, vh, svh).

      50
      
  • Get default static properties

    Returns {
        __staticProp: true;
        autoHide: boolean;
        axis: "x" | "y";
        class: string | false;
        container: Window | HTMLElement | Snap;
        draggable: boolean;
        parent: false | HTMLElement;
        resizeDebounce: number;
    }

    • __staticProp: true
    • autoHide: boolean

      Automatically hides the scrollbar when inactive.

      true
      
    • axis: "x" | "y"

      Defines the scrolling axis for the scrollbar.

      • 'x' for horizontal scrolling.
      • 'y' for vertical scrolling.
      'y'
      
    • class: string | false

      Custom CSS class to be applied to the scrollbar track. If false, no additional class is applied.

      false
      
    • container: Window | HTMLElement | Snap

      The element to which the scrollbar is applied. Can be either the window or a specific HTML element.

      window
      
    • draggable: boolean

      Determines whether the scrollbar thumb is draggable.

      true
      
    • parent: false | HTMLElement

      The parent element where the scrollbar should be appended. If false, the scrollbar is appended directly to the container. For proper behavior, use parent when applying the scrollbar to an HTML element.

      false
      
    • resizeDebounce: number

      Debounce time (in milliseconds) for handling resize events. Helps improve performance by limiting the frequency of resize calculations.

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

    Parameters

    • action: () => void

      The function to execute during destruction.

    Returns void