element-from-point

1.0.0 • Public • Published

ElementFromPoint.js

NPM version

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

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 = require("element-from-point")
 
document.addEventListener("mousedown", function(ev) {
  var el = elementFromPoint(ev.clientX, ev.clientY)
})

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.

Readme

Keywords

Package Sidebar

Install

npm i element-from-point

Weekly Downloads

71

Version

1.0.0

License

none

Last publish

Collaborators

  • moll