Package Exports
- mouse-event-offset
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (mouse-event-offset) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
mouse-event-offset
Gets the offsetX/offsetY from a mouse event, relative to the top left of the target (i.e. clicked) element. This uses currentTarget (i.e. the element that you specified for the event) and falls back to srcElement.
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:
clientRectis a pre-computed bounding client rect or offset (e.g. to avoid reflows), defaults to use the target'sgetBoundingClientRect()(or offset(0, 0)in the case of window/body)clientXis the client x position, defaults toevent.clientXclientYis the client y position, defaults toevent.clientY
License
MIT, see LICENSE.md for details.
