mouse-event-offset
Gets the offsetX/offsetY from a mouse event, relative to the top left of the target (i.e. clicked) element.
var offset = require('mouse-event-offset')
var events = require('dom-events')
events.on(element, 'click', function(e) {
var pos = offset(e)
console.log(pos.x, pos.y)
})
Usage
offset(event[, options])
Pass an event object to the function, and a position with { x, y }
is returned. The options:
clientRect
is a pre-computed bounding client rect (e.g. to avoid reflows), defaults to use the target's getBoundingClientRect()
clientX
is the client x position, defaults to event.clientX
clientY
is the client y position, defaults to event.clientY
License
MIT, see LICENSE.md for details.