Web APIs
IntersectionObserver()
Creates an asynchronous geometric intersection observer. Options include root, rootMargin and threshold.
Formal Syntax & Structure
javascript syntaxjavascript
new IntersectionObserver(callback, [options])Parameters & Attributes
| Name | Type | Description |
|---|---|---|
| callback | function | Receives entries and observer. |
| options | IntersectionObserverInit | Root and thresholds. |
Return Value
IntersectionObserver
Observer instance.
Working Example
Example Snippetjavascript
(async () => {const o=new IntersectionObserver(()=>{}, {threshold:[0.75,0.25]});console.log(JSON.stringify(o.thresholds),o.root===null);o.disconnect();})()