如何构建一个检测滑动和点击事件的面板

How to build a panel that detects both swipe and click events

使用 dojo.gesture.swipe 我希望能够监听面板上的任何滑动事件并相应地更改其内容:

on(myPanel, swipe.end, lang.hitch(this, function(e) {
    if (e.dx < -100) {                      
        //do something
        e.stopPropagation();
        event.stop(e);
    }
}));

这段代码可以很好地检测滑动事件并在滑动动作足够大时执行某些操作。

但是在我的面板上我有其他按钮点击监听器不再工作:

on(myButton, 'click', lang.hitch(this, 'onMyButtonClick'))`);

知道会出什么问题吗?

谢谢

我在 'tap' 事件中缺少监听器:

on(myButton, tap, lang.hitch(this, onMyButtonClick));

这意味着当使用 dojo.gesture 时,如果同时针对触摸屏和经典屏幕,应该监听 click AND tap 事件。