Function: createIntersectionObserver()
ts
function createIntersectionObserver(
target,
callback,
options?): IntersectionObserver;Creates an IntersectionObserver and observes one or more targets.
Parameters
| Parameter | Type | Description |
|---|---|---|
target | Element | readonly Element[] | The target element or element list. |
callback | IntersectionObserverCallback | The observer callback. |
options? | IntersectionObserverInit | The observer options. |
Returns
IntersectionObserver
The created observer.
Example
ts
const el = document.createElement('div')
document.body.appendChild(el)
const obs = createIntersectionObserver(el, (entries) => console.log(entries))
console.log(obs instanceof IntersectionObserver)Since
1.0.0