开发者社区> 镜像站> NPM> dom.position
dom.position
dom position functions
Last updated 7 years ago by shtylman .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install dom.position 
SYNC missed versions from official npm registry.

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
});

Current Tags

  • 0.0.0                                ...           latest (7 years ago)

1 Versions

  • 0.0.0                                ...           7 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (0)
None
Dev Dependencies (0)
None