Skip to content
A consistent cross-browser document.elementFromPoint function. Works around idiosyncracies of old WebKits et al.
Makefile JavaScript
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
doc
.gitignore
.npmignore
CHANGELOG.md
LICENSE
Makefile
README.md
index.js
package.json

README.md

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.

You can’t perform that action at this time.