我一直在使用这篇文章(和其他一些文章)来尝试在我的应用程序中实现手势识别,它确实有效。但是,我想做的是检测多个手势;例如,滑动和触摸。我似乎无法做的是确定MouseUp
事件是由手势结束还是由单次触摸引起的。
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
and manipulationcompleted
,但其中一个。