Skip to content

Function: onIntersection()

onIntersection(element, options?): Stream<boolean>

Defined in: streams/onIntersection.ts:17

Creates a stream that emits true when a given element enters the viewport and false when it leaves.

This operator is a wrapper around the IntersectionObserver API, making it easy to create reactive streams for "lazy loading" or triggering events when an element becomes visible. The stream will emit a value each time the intersection status changes.

Parameters

element

Element

The DOM element to observe for intersection changes.

options?

IntersectionObserverInit

Optional configuration for the observer, such as root, root margin, and threshold.

Returns

Stream<boolean>

A stream that emits true if the element is intersecting the viewport, and false otherwise.

Released under the MIT License.