Skip to main content

Interface: UseIntersectionObserverOptions

Defined in: use-intersection-observer.ts:6

Options for useIntersectionObserver.

Properties​

defaultIsIntersecting?​

optional defaultIsIntersecting?: 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?​

optional enabled?: 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?​

optional once?: 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?​

optional onChange?: (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?​

optional root?: 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?​

optional rootMargin?: 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?​

optional threshold?: 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.