Last active
May 16, 2019 22:38
-
-
Save alexsasharegan/6da9e9763e7f1670913a6038fa9fdc1d to your computer and use it in GitHub Desktop.
Adds a window global for IntersectionObserver support at `Symbol.for("@@support.IntersectionObserver")`.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
window[Symbol.for("@@support.IntersectionObserver")] = (function(w, k) { | |
let y = k.io in w && k.en in w && k.ra in w[k.en][k.pr]; | |
if (!y) { | |
return false; | |
} | |
if (!(k.ix in w[k.en][k.pr])) { | |
Object.defineProperty(w[k.en][k.pr], k.ix, { | |
get() { | |
return this[k.ra] > 0; | |
}, | |
}); | |
} | |
return true; | |
})(window, { | |
io: "IntersectionObserver", | |
en: "IntersectionObserverEntry", | |
ra: "intersectionRatio", | |
ix: "isIntersecting", | |
pr: "prototype" | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment