Package Exports
- mouse-pos
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-pos) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
mouse-pos
A super simple cross-browser library to get the correct coordinates of your mouse event. Just pass the method the event obj and it will return the distance you need (as array).
npm install mouse-posuse it like this
var mouse = require("mouse-pos");
var el = document.getElementById("outside");
el.addEventListener("click", function(e){
console.log("rel coords", mouse.getRel(e)); // e.g. [5,5]
console.log("abs coords", mouse.getAbs(e)); // e.g. [205,205]
});rel(e) - relative to the target
[x,y]
abs(e) - absolute to the screen
[x,y]
wheelDelta(e)
float of pixels the mouse wheel moved. Could be negative.
Enjoy!