Function onScroll

  • Add onScroll event listener to the provided container (DOM element, custom scroll, or window). It automatically manages multiple scroll listeners by stacking them in instances.

    If an instance already exists for the container, it adds the new callback to the existing stack. Otherwise, it creates a new scroll listener.

    This function supports both native scrollable elements and CustomScroll instances.

    Parameters

    Returns IRemovable

    Example

    onScroll({
    container: window,
    callback: ({ scrollLeft, scrollTop }) => console.log(scrollLeft, scrollTop),
    isPassive: true,
    });