この記事 (および他の記事) を使用して、アプリにジェスチャ認識を実装しようとしましたが、うまくいきました。ただし、私がやりたいのは、複数のジェスチャーを検出することです。たとえば、スワイプやタッチです。私ができないように見えるのは、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
かmanipulationcompleted
一方です。