我正在使用ImpactJS引擎构建游戏(http://impactjs.com/)。游戏需要拖动和滑动等手势。因此,HammerJS集成在代码上。
在下面的代码段中,当左键单击绑定为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.
}
这里似乎有什么问题?感谢。
答案 0 :(得分:0)
这解决了我的问题:
Hammer( this.canvas ).on( "dragup", this.onDragUp.bind( this ), {prevent_default: true} );