ImpactJS and HammerJS mouse input conflicts with one another

130 Views Asked by At

I'm building a game using the ImpactJS engine (http://impactjs.com/). The game requires gestures such as drag and swipe. Hence, HammerJS is integrated on the code.

In the snippet below, the release event callback is not triggered when the left click is binded as ig.input.

init : function() {
    // The onRelease() is triggered when this is commented out.
    //ig.input.bind( ig.KEY.MOUSE1, "click" );

    Hammer( this.canvas ).on( "dragup", this.onDragUp.bind( this ) );
    Hammer( this.canvas ).on( "dragdown", this.onDragDown.bind( this ) );
    Hammer( this.canvas ).on( "release", this.onRelease.bind( this ) );
},

onRelease : function() {
    alert( "Released!" );
}

onDragUp : function( event ) { 
    //No problem here.
}

onDragDown : function( event ) {
   //No problem here.
} 

What seems to be the problem here? Thanks.

1

There are 1 best solutions below

0
On

This solved my problem:

Hammer( this.canvas ).on( "dragup", this.onDragUp.bind( this ), {prevent_default: true} );

https://github.com/EightMedia/hammer.js/issues/538