Interface: UseIntersectionObserverOptions
Defined in: use-intersection-observer.ts:6
Options for useIntersectionObserver.
Properties
defaultIsIntersecting?
optionaldefaultIsIntersecting?:boolean
Defined in: use-intersection-observer.ts:41
Value reported on the server and until the element has been observed.
Only read on the first render. Defaults to false.
enabled?
optionalenabled?:boolean
Defined in: use-intersection-observer.ts:30
Set to false to pause observing, for example while a feature is off.
The last value is kept, and observing resumes when it is true again.
Defaults to true.
once?
optionalonce?:boolean
Defined in: use-intersection-observer.ts:36
Stop observing after the element first intersects and keep reporting
true, which suits lazy-loading and reveal-once animations. Defaults to
false.
onChange?
optionalonChange?: (entry) =>void
Defined in: use-intersection-observer.ts:48
Called with the raw IntersectionObserverEntry for every notification,
including the first one right after observing starts. Use it to read
intersectionRatio, boundingClientRect and more, or to run side effects
without waiting for a re-render. The latest callback is always used.
Parameters
entry
IntersectionObserverEntry
Returns
void
root?
optionalroot?:Document|Element|null
Defined in: use-intersection-observer.ts:12
The element (or document) used as the viewport for the check. Defaults to the browser viewport. Pass a scrollable container to track visibility inside it. Passing a new element re-observes.
rootMargin?
optionalrootMargin?:string
Defined in: use-intersection-observer.ts:18
Grows or shrinks the root's box before computing intersections, using CSS
margin syntax, for example "200px" to start loading before an element
scrolls into view. Defaults to "0px".
threshold?
optionalthreshold?:number|number[]
Defined in: use-intersection-observer.ts:24
How much of the element must be visible, from 0 to 1, before it counts
as intersecting. Pass an array to be notified at several ratios (use
onChange to read entry.intersectionRatio). Defaults to 0.