ev-pos
relative position of mouse/touch events to element
Usage
npm i ev-pos
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.