mouse-event-offset
Computes the [ offsetX, offsetY ]
from a mouse or touch event, relative to the top left of the target
element.
var offset = window
Usage
position = offset(event, [target], [out])
Pass a MouseEvent or TouchEvent as event
.
Optionally, you can specify a target
element which the touch event should be relative to. Defaults to event.currentTarget
, falling back to event.srcElement
for older IE.
You can also specifiy out
to store the position in that array, and avoid creating a new one.
Changelog
3.x
new version; simpler API, less assumptions, avoids GC thrashing2.x
usesev.currentTarget
instead ofev.target
1.x
simple implementation usingev.target || ev.srcElement
License
MIT, see LICENSE.md for details.