Coder Social home page Coder Social logo

robertbadas / js-element-from-point Goto Github PK

View Code? Open in Web Editor NEW

This project forked from moll/js-element-from-point

0.0 1.0 0.0 7 KB

A consistent cross-browser document.elementFromPoint function. Works around idiosyncracies of old WebKits et al.

License: Other

Makefile 62.14% JavaScript 37.86%

js-element-from-point's Introduction

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 [email protected] or create an issue online.

js-element-from-point's People

Contributors

moll avatar orthographic-pedant avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.