R
fn

useScroll

v0.0.15testeddemo

Reactive scroll position and state for an element or the window, with arrived-edge detection (RTL-aware), scroll directions, an `isScrolling` flag, optional throttling, and a `measure()` method for manual re-sync.

Example

ts
const { x, y, isScrolling, arrivedState, measure } = useScroll(el);

Demo

Loading demo…

Signature

ts
export function useScroll(
  target: UseScrollTarget,
  options: UseScrollOptions ={ ... }

Parameters

ParameterTypeDescription
targetUseScrollTargetThe scroll container (can be reactive)
options?UseScrollOptionsOptions

Returns

UseScrollReturnReactive position, scroll state, arrived edges, directions, and `measure`