ElementFromPoint.js
ElementFromPoint.js is a cross-browser document.elementFromPoint
function that works consistently across browsers that may implement document.elementFromPoint
differently.
For example, older iOS or Android devices (with WebKit) implement elementFromPoint
such that it takes page (pageX/Y
) coordinates, not viewport (clientX/Y
) coordinates. Use this function to always work with viewport coordinates.
Further reading
- document.elementFromPoint at MDN
- QuirksMode's W3C DOM Compatibility
- QuirksMode's Great WebKit Comparison Table
Installing
Installing on Node.js
npm install element-from-point
Using
Require and use it as you would use document.elementFromPoint
.
Just make sure to pass in viewport coordinates and you're all set.
var elementFromPoint = document
License
ElementFromPoint.js is released under a Lesser GNU Affero General Public License, which in summary means:
- You can use this program for no cost.
- You can use this program for both personal and commercial reasons.
- You do not have to share your own program's code which uses this program.
- You have to share modifications (e.g bug-fixes) you've made to this program.
For more convoluted language, see the LICENSE
file.
About
Andri Möll typed this and the code.
Monday Calendar supported the engineering work.
If you find ElementFromPoint.js needs improving, ping me at andri@dot.ee or create an issue online.