Function createIsPageScrolling

  • Creates an instance to check whether the page is currently scrolling. This function manages the scroll state across multiple instances, ensuring the listener is created only once.

    Returns {
        destroy: (() => void);
        get: (() => boolean);
    }

    • destroy: (() => void)
        • (): void
        • Removes the current instance's ID from the tracking list and destroys the listener if no other IDs exist.

          Returns void

    • get: (() => boolean)
        • (): boolean
        • Returns boolean

          • Returns whether the page is currently scrolling.

    Example

    const scrollChecker = createIsPageScrolling();

    // Check if page is scrolling
    const isPageScrolling = scrollChecker.get(); // => true or false

    // Destroy the instance when not needed
    scrollChecker.destroy();