3

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

したがって、 と の両方を処理する必要がありますが、どちらprocessUpmanipulationcompleted一方です。

4

2 に答える 2

1

これを行う方法を見つけましたが、きれいではありません:

var eventFlag = 0;

var processUp = function (args) {
    try {
        recognizer.processUpEvent(args.currentPoint);

        if (eventFlag == 0) {
           // do stuff
        } else {
           eventFlag = 0;
        }
    }
    catch (e) { }
}

recognizer.gestureSettings = Windows.UI.Input.GestureSettings.manipulationTranslateX
recognizer.addEventListener('manipulationcompleted', function (e) {
    var dx = e.cumulative.translation.x
    //Do something with direction here
    eventFlag = 1;
});
于 2013-05-09T16:45:45.727 に答える