A module for getting the current mouse position on an element, designed for use in games and animations.
mouse = mousePosition([element], [listener])
mousemove events. If you don't pass an element,
mouse will watch the entire browser window.
listener will attach the listener event to another element – helpful, for
example, to catch movement across a larger area but still receive positions
The current horizontal position of the mouse, in pixels.
The current vertical position of the mouse, in pixels.
The previous horizontal position of the mouse, in pixels.
The previous vertical position of the mouse, in pixels.
Called every time the mouse is moved anywhere on the targeted element.
Call this method at the end of each frame to update the
values – you won't get
mousemove events every frame, so if you don't update
this you might get incorrect values.
Call this method to remove the internal
mousemove event listener and any
move callbacks on the
MIT. See LICENSE.md for details.