Show:
Extends SimpleStream

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:

  • [options] Object optional

    Options

    • [direction] Number optional

      Direction to project movement onto. Options found in MouseInput.DIRECTION.

    • [scale=1] Number optional

      Scale the response to the mouse

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);
         });

Item Index

Properties

Properties

DIRECTION

Object static

Constrain the input along a specific axis.

Sub-properties: