Inputs.MouseInput Class
Extends SimpleStream
Defined in:
samsara/inputs/MouseInput.js:19
Wrapper for DOM mouse events. Converts
mousedown
-> start
mousemove
-> update
mouseup
-> end
MouseInput emits these events with the following payload data:
value
- Displacement in pixels from mousedown
delta
- Differential in pixels between successive mouse positions
velocity
- Velocity of mouse movement in pixels per second
cumulate
- Accumulated value over successive displacements
clientX
- DOM event clientX property
clientY
- DOM event clientY property
offsetX
- DOM event offsetX property
offsetY
- DOM event offsetY property
Constructor
Inputs.MouseInput
(
-
[options]
Parameters:
Example:
var surface = new Surface({
size : [100,100],
properties : {background : 'red'}
});
var mouseInput = new MouseInput({
direction : MouseInput.DIRECTION.X
});
mouseInput.subscribe(surface);
mouseInput.on('start', function(payload){
// fired on mouse down
console.log('start', payload);
});
mouseInput.on('update', function(payload){
// fired on mouse move
console.log('update', payload);
});
mouseInput.on('end', function(payload){
// fired on mouse up
console.log('end', payload);
});