Package Exports
- mouse-speed
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-speed) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
mouse-speed
Calculates mouse speed during the mousemove event.
Usage
var MouseSpeed = require("mouse-speed");
var speed = new MouseSpeed();
speed.init(onCalcSpeed);
var onCalcSpeed = function() {
var speedX = speed.speedX;
var speedY = speed.speedY;
// do anything you want with speed values
console.log(speedX, speedY);
};Create a new instance of mouse-speed in your project.
The speed values are accessed through the speedX and speedY properties on the instance.
The function passed to the instance will fire on every mousemove event.
speed.destroy(onDestroyFunc);
var onDestroyFunc = function() {
console.log("destroyed");
};To remove the event listener, call destroy on the instance of mouse-speed.
An optional function can be passed that will be called when the event listener is removed
License
MIT, see LICENSE.md for details.
