Hooks

useScrollPosition

Publisher

cermuel

50 hooks published

More from this publisher

useScrollPosition

Track page or container scroll coordinates.

useScrollPosition.tsx
import { useScrollPosition } from "@cermuel/hooks/react";export function useScrollPositionExample() {  const position = useScrollPosition();  return <p>{position.x}, {position.y}</p>;}

Props

Param
Type
Default Value
target?
MaybeTarget<Element | Window>

Returns

{ x: number; y: number; }