useScroll
Tracks the scroll position of a scrollable container element or the document window and exposes a reactive AnimationLink containing normalized x and y scroll offsets from 0 to 1.
Importing
1
import { useScroll } from '@infinityfx/lively/hooks';Usage
Scroll down inside this box...
Call signature
1
const link = useScroll<T extends HTMLElement>(target?)
Parameters
target?:
React.RefObject<T | null> Optional React ref targeting a scrollable element. Defaults to tracking the document viewport scroll if omitted.
Returns
link:
AnimationLink<{ x: number, y: number }> A reactive Link containing normalized x and y scroll offsets from 0 to 1.