intersection
Thin wrappers around IntersectionObserver for observing element
visibility, including a one-shot observeOnce helper.
Import: @rtorcato/browser-common/intersection
๐ MDN: Intersection Observer API ยท ๐ caniuse: intersectionobserver
Browser supportโ
| API | Chrome | Edge | Firefox | Safari | iOS Safari | Baseline |
|---|---|---|---|---|---|---|
IntersectionObserver | โ 51+ | โ 15+ | โ 55+ | โ 12.1+ | โ 12.2+ | Widely available |
โ
supported ยท โ partial ยท โ not supported ยท [n] see note. Generated from MDN browser-compat-data and web-features. caniuse: IntersectionObserver
Exampleโ
import { observeOnce, disconnectIntersectionObserver } from '@rtorcato/browser-common/intersection'
observeOnce(image, () => loadImage(image))
Exportsโ
observeIntersection(element, callback, options?)โ creates anIntersectionObserverand observeselementunobserveIntersection(observer, element)โ stops observingelementdisconnectIntersectionObserver(observer)โ disconnects the observer entirelyobserveOnce(element, callback, options?)โ firescallbackonce on first intersection, then disconnects
See the API reference for full signatures.