fn
useScroll
v0.0.15testeddemoReactive 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
| Parameter | Type | Description |
|---|---|---|
target | UseScrollTarget | The scroll container (can be reactive) |
options? | UseScrollOptions | Options |
Returns
UseScrollReturnReactive position, scroll state, arrived edges, directions, and `measure`