Skip to content

Instantly share code, notes, and snippets.

class ViewportObserver {
constructor() {
const intersectionObserverCallbackClosure = (observerEntries, which) => { this.intersectionObserverFired(observerEntries, which) }
this.viewportObserver = new IntersectionObserver(intersectionObserverCallbackClosure, {
root: null,
rootMargin: "0px 0px 0px 0px"
})
this.nearViewportObserver = new IntersectionObserver(intersectionObserverCallbackClosure, {
root: null,
rootMargin: "200% 0px 200% 0px"