Skip to content

Instantly share code, notes, and snippets.

@alexsasharegan
Last active May 16, 2019 22:38
Show Gist options
  • Save alexsasharegan/6da9e9763e7f1670913a6038fa9fdc1d to your computer and use it in GitHub Desktop.
Save alexsasharegan/6da9e9763e7f1670913a6038fa9fdc1d to your computer and use it in GitHub Desktop.
Adds a window global for IntersectionObserver support at `Symbol.for("@@support.IntersectionObserver")`.
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