Skip to content

Instantly share code, notes, and snippets.

@tomelam
Forked from iddan/elementsfrompoint.js
Created March 17, 2020 12:26
Show Gist options
  • Save tomelam/996c0f093624ef41a57322f45b372c0e to your computer and use it in GitHub Desktop.
Save tomelam/996c0f093624ef41a57322f45b372c0e to your computer and use it in GitHub Desktop.
document.elementsFromPoint Polyfill
'use strict';
if (!document.elementsFromPoint) {
document.elementsFromPoint = elementsFromPoint;
}
function elementsFromPoint(x, y) {
var parents = [];
var parent = void 0;
do {
if (parent !== document.elementFromPoint(x, y)) {
parent = document.elementFromPoint(x, y);
parents.push(parent);
parent.style.pointerEvents = 'none';
} else {
parent = false;
}
} while (parent);
parents.forEach(function (parent) {
return parent.style.pointerEvents = 'all';
});
return parents;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment