0

现在我正在开发基于html5和phoneGap的移动应用程序。JS名气是ember。应用程序的规范要求响应长按手势。但长按事件不是 ember 内置事件。

我应该怎么做才能识别手势并连接到事件处理(控制器或路由)?

4

1 回答 1

0

我能够做到这一点,mouseUpmouseDown你可以使用我确定的touchStart和事件。touchEnd这里

我设置了一个jsbin,但这是相关代码:

var myfunction = function() { 
  alert('held');
}

App.ApplicationView = Ember.View.extend({
  mouseDown: function(e){
   var runLater = Ember.run.later(this, myfunction, 1000);
    this.set('pressed', runLater);
  },

  mouseUp: function (e) { 
    Ember.run.cancel(this.get('pressed'));
  }
})
于 2013-12-24T14:20:13.733 回答