-
-
Save tomelam/996c0f093624ef41a57322f45b372c0e to your computer and use it in GitHub Desktop.
document.elementsFromPoint Polyfill
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
'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