Skip to content

Instantly share code, notes, and snippets.

@andreineculau
Forked from oslego/elementsFromPoint.js
Last active April 6, 2017 20:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andreineculau/27be426e793559d1ce4d69bc42a3c32d to your computer and use it in GitHub Desktop.
Save andreineculau/27be426e793559d1ce4d69bc42a3c32d to your computer and use it in GitHub Desktop.
let elementsFromPoint = function(x, y) {
let items = [];
let element;
do {
element = document.elementFromPoint(x, y);
if (!element || element === (items[0] || {}).element) {
break;
}
items.unshift({
element,
value: element.style.getPropertyValue('pointer-events'),
priority: element.style.getPropertyPriority('pointer-events')
});
element.style.setProperty('pointer-events', 'none', 'important');
} while (true);
_.each(items, function(item) {
item.element.style.setProperty(
'pointer-events',
item.value ? item.value : '', item.priority
);
});
return _.map(items, 'element');
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment