javascript - WinJS gestureRecognizer - how to trap multiple gestures -
i've been using this article (and others) try , implement gesture recognition in app, , work. however, want detect multiple gestures; example, swipe, , touch. don't seem able establish whether mouseup
event caused end of gesture, or single touch.
function processupevent(e) { lastelement = e.currenttarget; gesturerecognizer.processupevent(e.currentpoint); processtouchevent(e.currentpoint); }
what happens processed both. how can detect whether user has 'let go' of screen swipe, or touch?
edit:
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 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);
so need handle both processup
, manipulationcompleted
, 1 or other.
you can have @ "input" demo in codeshow. install codeshow app (http://aka.ms/codeshowapp) , @ pointer input demo , "see code" or go source code on codeplex. hope helps.
Comments
Post a Comment