interface ScrollPosition { x: number; y: number; } /** * Hook that tracks the current window scroll position in real-time. * * Automatically updates when the user scrolls and handles SSR scenarios * by safely checking for window availability. * * @returns An object containing: * - `x`: Horizontal scroll position in pixels * - `y`: Vertical scroll position in pixels * * @example * ```tsx * function ScrollIndicator() { * const { x, y } = useScrollPosition(); * * return ( *
Horizontal: {x}px
*Vertical: {y}px
* {y > 100 && ( * * )} *