UNPKG

@supunlakmal/hooks

Version:

A collection of reusable React hooks

15 lines (14 loc) 681 B
import { RefObject } from 'react'; interface ScrollPosition { x: number; y: number; } /** * Custom hook to track the scroll position of the window or a specific element. * * @param {RefObject<Element> | Window | null} [element] - The target element or window to track scroll position for. Defaults to window. * @param {number} [throttleMs=100] - Throttle time in milliseconds to limit scroll event handling. Set to 0 to disable throttling. * @returns {ScrollPosition} An object containing the current x and y scroll position. */ export declare const useScrollPosition: (element?: RefObject<Element> | Window | null, throttleMs?: number) => ScrollPosition; export {};