我一直在使用this文章(以及其他人)尝试在我的应用中实现手势识别,并且它确实有效。但是,我想要做的是检测多个手势;例如,轻扫和触摸。我似乎无法做到的事情是确定MouseUp
事件是由手势结束还是通过单键触发引起的。WinJS gestureRecognizer - 如何捕捉多个手势
function processUpEvent(e) {
lastElement = e.currentTarget;
gestureRecognizer.processUpEvent(e.currentPoint);
processTouchEvent(e.currentPoint);
}
当前发生的是它处理两个。如何检测用户是否放弃了屏幕刷卡或触摸?
编辑:
var recognizer = new Windows.UI.Input.GestureRecognizer();
recognizer.gestureSettings = Windows.UI.Input.GestureSettings.manipulationTranslateX
recognizer.addEventListener('manipulationcompleted', function (e) {
var dx = e.cumulative.translation.x
//Do something with direction here
});
var processUp = function (args) {
try {
recognizer.processUpEvent(args.currentPoint);
}
catch (e) { }
}
canvas.addEventListener('MSPointerDown', function (args) {
try {
recognizer.processDownEvent(args.currentPoint);
}
catch (e) { }
}, false);
canvas.addEventListener('MSPointerMove', function (args) {
try {
recognizer.processMoveEvents(args.intermediatePoints);
}
catch (e) { }
}, false);
canvas.addEventListener('MSPointerUp', processUp, false);
canvas.addEventListener('MSPointerCancel', processUp, false);
所以,我需要同时处理processUp
和manipulationcompleted
,但一个或另一个。
我不知道这个回答我的问题。虽然这确实包括拖动,但我需要捕捉方向。我已经用一些更具体的细节更新了我的问题。 – 2013-05-04 10:00:48