UNPKG

@supunlakmal/hooks

Version:

A collection of reusable React hooks

18 lines (17 loc) 922 B
interface ScrollSpyOptions { /** The container element whose scroll position is monitored. Defaults to window. */ containerRef?: React.RefObject<HTMLElement | null>; /** Pixel offset from the top of the container to trigger activation. Can be negative. Defaults to 0. */ offset?: number; /** Throttle delay in milliseconds for scroll event handling. Defaults to 100. */ throttleMs?: number; } /** * Monitors scroll position to determine which element/section is currently active in the viewport. * * @param sectionRefs An array of React refs attached to the section elements to be monitored. * @param options Configuration options for offset and container. * @returns The id of the currently active section element, or null if none are active. */ export declare const useScrollSpy: (sectionRefs: React.RefObject<HTMLElement | null>[], options?: ScrollSpyOptions) => string | null; export {};