JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 15
  • Score
    100M100P100Q49762F
  • License MIT

A node module to calculate mouse speed.

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 via the event object, returning x and y speed values as an object.

Usage

speed(e)

const mouseSpeed = require('mouse-speed');

window.addEventListener('mousemove', (e) => {
  const speed = mouseSpeed(e);
  console.log(speed.x, speed.y);
})

To be used in the mousemove event.

By passing in the event object, speed is calculated and returned as an object with x and y values.

speed(e, object)

const mouseSpeed = require('mouse-speed');

const speedTracker = {};

window.addEventListener('mousemove', (e) => {
  const speed = mouseSpeed(e, speedTracker);
  console.log(speedTracker.speedX, speedTracker.speedY);
})

An object can be passed as an optional parameter.

This object will now have two new values accessible as object.speedX and object.speedY.

License

MIT, see LICENSE.md for details.