NGL@0.10.4 Home Manual Reference Source GalleryRepository
import MouseObserver from 'ngl/src/stage/mouse-observer.js'
public class | source

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 touch-clicking) events
mouseObserver.signals.clicked.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

Position on page when clicked

public

Flag indicating if the mouse is hovering

public

Timestamp of last mouse move

public

Flag indicating if the meta key is pressed

public

Flag indicating if the mouse is moving

public

Position on page

public

Flag indicating if the mouse is pressed down

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

Public Constructors

public constructor(domElement: Element, params: Object) source

Params:

NameTypeAttributeDescription
domElement Element

the dom element to observe mouse events in

params Object

parameters object

params.hoverTimeout Integer

timeout until the MouseSignals.hovered signal is fired, set to -1 to ignore hovering

Public Members

public altKey: Boolean source

Flag indicating if the alt key is pressed

public buttons: Integer source

Indicates which mouse buttons were pressed: 0: No button; 1: Left button; 2: Right button; 4: Middle button

public canvasPosition: Vector2 source

Position on dom element

public ctrlKey: Boolean source

Flag indicating if the ctrl key is pressed

public down: Vector2 source

Position on page when clicked

public hovering: Boolean source

Flag indicating if the mouse is hovering

public lastMoved: Number source

Timestamp of last mouse move

public metaKey: Boolean source

Flag indicating if the meta key is pressed

public moving: Boolean source

Flag indicating if the mouse is moving

public position: Vector2 source

Position on page

public pressed: Boolean source

Flag indicating if the mouse is pressed down

public prevPosition: Vector2 source

Previous position on page

public scrolled: Boolean source

Flag indicating if there was a scolling event since the last mouse move

public shiftKey: Boolean source

Flag indicating if the shift key is pressed

public signals: MouseSignals source

Events emitted by the mouse observer

public which: Integer source

Indicates which mouse button was pressed: 0: No button; 1: Left button; 2: Middle button; 3: Right button