Optional
name: string// Javascript
new MouseHandler( document.getElementById('mycanvas') )
.drag( function(e) {
console.log( 'Mouse dragged: ' + JSON.stringify(e) );
if( e.params.leftMouse ) ;
else if( e.params.rightMouse ) ;
} )
.move( function(e) {
console.log( 'Mouse moved: ' + JSON.stringify(e.params) );
} )
.up( function(e) {
console.log( 'Mouse up. Was dragged?', e.params.wasDragged );
} )
.down( function(e) {
console.log( 'Mouse down.' );
} )
.click( function(e) {
console.log( 'Click.' );
} )
.wheel( function(e) {
console.log( 'Wheel. delta='+e.deltaY );
} )
// Typescript
new MouseHandler( document.getElementById('mycanvas') )
.drag( (e:XMouseEvent) => {
console.log( 'Mouse dragged: ' + JSON.stringify(e) );
if( e.params.leftMouse ) ;
else if( e.params.rightMouse ) ;
} )
.move( (e:XMouseEvent) => {
console.log( 'Mouse moved: ' + JSON.stringify(e.params) );
} )
.up( (e:XMouseEvent) => {
console.log( 'Mouse up. Was dragged?', e.params.wasDragged );
} )
.down( (e:XMouseEvent) => {
console.log( 'Mouse down.' );
} )
.click( (e:XMouseEvent) => {
console.log( 'Click.' );
} )
.wheel( (e:XWheelEvent) => {
console.log( 'Wheel. delta='+e.deltaY );
} )
MouseHandler
Private
elementPrivate
handlersPrivate
installedPrivate
listenersPrivate
mousePrivate
mousePrivate
mousePrivate
nameInstaller function to listen for a specific event: mouse-click. Pass your callbacks here.
Note: this support chaining.
The click-callback to listen for.
this
click
MouseHandler
Private
destroyInstaller function to listen for a specific event: mouse-down. Pass your callbacks here.
Note: this support chaining.
The down-callback to listen for.
this
down
MouseHandler
Installer function to listen for a specific event: mouse-drag. Pass your callbacks here.
Note: this support chaining.
The drag-callback to listen for.
this
drag
MouseHandler
Private
listenPrivate
mkPrivate
Build the extended event params.
The mouse event to get the relative position for.
The name of the firing event.
mkParams
MouseHandler
Installer function to listen for a specific event: mouse-move. Pass your callbacks here.
Note: this support chaining.
The move-callback to listen for.
this
move
MouseHandler
Private
relPrivate
throwPrivate
unlistenInstaller function to listen for a specific event: mouse-up. Pass your callbacks here.
Note: this support chaining.
The up-callback to listen for.
this
up
MouseHandler
Installer function to listen for a specific event: mouse-wheel. Pass your callbacks here.
Note: this support chaining.
The wheel-callback to listen for.
this
wheel
MouseHandler
Classdesc
A simple mouse handler for demos. Use to avoid load massive libraries like jQuery.
Requires
XYCoords