mouse-change
Advanced tools
Comparing version 1.2.1 to 1.3.0
require('../mouse-listen')(function(buttons, x, y, mods) { | ||
document.body.innerHTML = | ||
'<p>Buttons: 0b' + buttons.toString(2) + | ||
', x:' + x + | ||
', y:' + y + | ||
document.body.innerHTML = | ||
'<p>Buttons: 0b' + buttons.toString(2) + | ||
', x:' + x + | ||
', y:' + y + | ||
', mods:' + JSON.stringify(mods) + '</p>' | ||
}) | ||
}) |
@@ -8,3 +8,2 @@ 'use strict' | ||
function mouseListen(element, callback) { | ||
if(!callback) { | ||
@@ -60,3 +59,3 @@ callback = element | ||
y = nextY||0 | ||
callback(buttonState, x, y, mods) | ||
callback && callback(buttonState, x, y, mods) | ||
} | ||
@@ -81,3 +80,3 @@ } | ||
mods.shift = mods.alt = mods.control = mods.meta = false | ||
callback(0, 0, 0, mods) | ||
callback && callback(0, 0, 0, mods) | ||
} | ||
@@ -88,3 +87,3 @@ } | ||
if(updateMods(ev)) { | ||
callback(buttonState, x, y, mods) | ||
callback && callback(buttonState, x, y, mods) | ||
} | ||
@@ -91,0 +90,0 @@ } |
{ | ||
"name": "mouse-change", | ||
"version": "1.2.1", | ||
"version": "1.3.0", | ||
"description": "Mouse state change listener", | ||
@@ -5,0 +5,0 @@ "main": "mouse-listen.js", |
@@ -26,7 +26,7 @@ mouse-change | ||
#### `var l = require('mouse-change')([element,] onchange(buttons,x,y,mods))` | ||
#### `var l = require('mouse-change')([element, onchange(buttons,x,y,mods)])` | ||
Listens for any mouse state changes on the given element. | ||
* `element` is an optional element | ||
* `onchange(buttons,x,y,mods)` is called every time that the mouse state changes inside `element` | ||
* `onchange(buttons,x,y,mods)` is an optional callback which gets called every time that the mouse state changes inside `element` | ||
+ `buttons` is the state of the mouse buttons | ||
@@ -44,3 +44,3 @@ + `x` is the x coordinate of the mouse | ||
#### `l.enabled` | ||
Toggles whether or not | ||
Toggles whether or not | ||
@@ -47,0 +47,0 @@ #### `l.x` |
8404
178