MouseObserver
Mouse observer
Example:
// listen to mouse moving (and touch-moving) events
mouseObserver.moved.moved.add( function( deltaX, deltaY ){ ... } );
// listen to scrolling (and pinching) events
mouseObserver.signals.scrolled.add( function( delta ){ ... } );
// listen to dragging (and touch-dragging) events
mouseObserver.signals.dragged.add( function( deltaX, deltaY ){ ... } );
// listen to clicking (and tapping) events
mouseObserver.signals.clicked.add( function(){ ... } );
// listen to double clicking (and double tapping) events
mouseObserver.signals.doubleClicked.add( function(){ ... } );
// listen to hovering events
mouseObserver.signals.hovered.add( function(){ ... } );
Constructor Summary
Public Constructor | ||
public |
constructor(domElement: Element, params: Object) |
Member Summary
Public Members | ||
public |
Flag indicating if the alt key is pressed |
|
public |
Indicates which mouse buttons were pressed: 0: No button; 1: Left button; 2: Right button; 4: Middle button |
|
public |
Position on dom element |
|
public |
Flag indicating if the ctrl key is pressed |
|
public |
|
|
public |
|
|
public |
|
|
public |
Position on page when clicked |
|
public |
|
|
public |
|
|
public |
Flag indicating if the mouse is hovering |
|
public get |
|
|
public |
|
|
public |
Timestamp of last mouse move |
|
public |
|
|
public |
Flag indicating if the meta key is pressed |
|
public |
Flag indicating if the mouse is moving |
|
public |
|
|
public |
Position on page |
|
public |
Flag indicating if the mouse is pressed down |
|
public |
|
|
public |
Previous position on page |
|
public |
Flag indicating if there was a scolling event since the last mouse move |
|
public |
Flag indicating if the shift key is pressed |
|
public |
Events emitted by the mouse observer |
|
public |
Indicates which mouse button was pressed: 0: No button; 1: Left button; 2: Middle button; 3: Right button |
Method Summary
Public Methods | ||
public |
dispose() |
|
public |
|
Private Methods | ||
private |
|
|
private |
listen to mouse actions |
|
private |
|
|
private |
|
|
private |
_onMousemove(event: Event): undefined handle mouse move |
|
private |
_onMouseup(event: Event): undefined handle mouse up |
|
private |
_onMousewheel(event: Event): undefined handle mouse scroll |
|
private |
|
|
private |
|
|
private |
|
|
private |
|
|
private |
_setKeys() |
Public Constructors
public constructor(domElement: Element, params: Object) source
Params:
Name | Type | Attribute | Description |
domElement | Element | the dom element to observe mouse events in |
|
params | Object | parameters object |
|
params.hoverTimeout | Integer | timeout in ms until the MouseSignals.hovered signal is fired, set to -1 to ignore hovering |
|
params.handleScroll | Boolean | whether or not to handle scroll events |
|
params.doubleClickSpeed | Integer | max time in ms to trigger double click |
Public Members
public buttons: Integer source
Indicates which mouse buttons were pressed: 0: No button; 1: Left button; 2: Right button; 4: Middle button
public domElement source
public doubleClickPending source
public doubleClickSpeed source
public handleScroll source
public hoverTimeout source
public get key source
public lastClicked source
public lastTouchDistance source
public overElement source
public prevClickCP source
Public Methods
public dispose() source
public setParameters() source
Private Methods
private _distance() source
private _listen(): undefined source
listen to mouse actions
Emit:
MouseSignals.clicked |
when clicked |
MouseSignals.hovered |
when hovered |
private _onContextmenu() source
private _onMousedown() source
private _onMousemove(event: Event): undefined source
handle mouse move
Params:
Name | Type | Attribute | Description |
event | Event | mouse event |
Emit:
MouseSignals.moved |
when moved |
MouseSignals.dragged |
when dragged |
private _onMouseup(event: Event): undefined source
handle mouse up
Params:
Name | Type | Attribute | Description |
event | Event | mouse event |
Emit:
MouseSignals.doubleClicked |
when double clicked |
MouseSignals.dropped |
when dropped |
private _onMousewheel(event: Event): undefined source
handle mouse scroll
Params:
Name | Type | Attribute | Description |
event | Event | mouse event |
Emit:
MouseSignals.scrolled |
when scrolled |