ev-pos

relative position of mouse/touch events to element

  • ev-pos

Downloads in past

Stats

StarsIssuesVersionUpdatedCreatedSize
ev-pos
111.0.17 years ago7 years agoMinified + gzip package size for ev-pos in KB

Readme

ev-pos
stable
relative position of mouse/touch events to element

Usage

npm i ev-pos
NPM
var evPos = require('ev-pos');

document.querySelector('.some-element').addEventListener('click', function(ev){
    //position relative to ev.currentTarget
    var p1 = evPos(ev);
    //position relative to document.body
    var p2 = evPos(ev, document.body);
});

API

evPos(event, toElement)
toElement defaults to ev.currentTarget

Example

npm i && npm run test-visual

(expects beefy
to be installed globally)

Licence

MIT, see LICENSE.md
for details.