dom.position

0.0.0 • Public • Published

dom.position

get the coordinates of the element relative to the document

examples

mouse coordinates inside of an element

var pos = require('dom.position');
 
div.addEventListener('mouseclick', function(ev) {
    var ppos = pos(ev.currentTarget);
 
    var x = ev.clientX - ppos.left;
    var y = ev.clientY - ppos.top;
 
    // coordinates {x,y} are relative to the click container
});

Dependencies (0)

    Dev Dependencies (0)

      Package Sidebar

      Install

      npm i dom.position

      Weekly Downloads

      15

      Version

      0.0.0

      License

      MIT

      Last publish

      Collaborators

      • defunctzombie