【问题标题】:ImpactJS and HammerJS mouse input conflicts with one anotherImpactJS 和 HammerJS 鼠标输入相互冲突
【发布时间】:2014-08-20 13:50:51
【问题描述】:

我正在使用 ImpactJS 引擎 (http://impactjs.com/) 构建游戏。游戏需要拖动和滑动等手势。因此,HammerJS 集成在代码中。

在下面的sn-p中,左键绑定为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.
} 

这里似乎有什么问题?谢谢。

【问题讨论】:

    标签: javascript html hammer.js impactjs


    【解决方案1】:

    这解决了我的问题:

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

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

    【讨论】:

      猜你喜欢
      • 2020-11-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-12-07
      • 2020-06-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多