import { ScrollInfo, ScrollProps } from './useDetectScroll.types'; /** * useDetectScroll hook. * * This hook provides a mechanism to detect the scroll direction and position. * It will return the scroll direction as a string (up, down, left, right, or still) based on user scrolling, * as well as the scroll position from the top, bottom, left, and right edges of the page. * * @example * * import useDetectScroll, { Axis, Direction } from '@smakss/react-scroll-direction'; * * function App() { * const customElementRef = useRef(null); * const [customElement, setCustomElement] = useState(); * * const { scrollDir, scrollPosition } = useDetectScroll({ * target: customElement, * thr: 100, * axis: Axis.Y, * scrollUp: Direction.Up, * scrollDown: Direction.Down, * still: Direction.Still * }); * * useEffect(() => { * if (customElementRef.current) { * setCustomElement(customElementRef.current); * } * }, [customElementRef]); * * return ( *
*

Current scroll direction: {scrollDir}

*

Scroll position - Top: {scrollPosition.top}, Bottom: {scrollPosition.bottom}, * Left: {scrollPosition.left}, Right: {scrollPosition.right}

*
* ); * } * * @param {ScrollProps} props - The properties related to scrolling. * @returns {ScrollInfo} - The current direction and position of scrolling. */ declare function useDetectScroll(props?: ScrollProps): ScrollInfo; export default useDetectScroll;