useScrollProgress
Registers a “scroll observer” on ref and executes callback when
the observed element is scrolled inside the viewport.
- @param
ref- Ref of the element to observe. - @param
callback- Callback invoked with progress data. - @param
options- Configuration (friction, precision, observer options, etc.). - @returns void
Example
const ref = useRef<HTMLDivElement>(null);
useScrollProgress(ref, (entry) => {
console.log('The element\'s inner progress is:', entry.innerProgress)
console.log('The element\'s outer progress is:', entry.outerProgress)
})UseScrollProgressEntry
Data provided to the scroll progress callback.
UseScrollProgressCallback
Callback type invoked with scroll progress data.
UseScrollProgressOptions
Options for useScrollProgress.
Extends IntersectionObserverInit with extra settings for smoothing and control.