how to swipe continuously with MSGesture? RRS feed

  • Question

  • Hi, I am writing an app that where in I can swipe continuously on an element, however when I swipe first it works, but while (am assuming - its in its inertial state) I swipe again it doesn't work, however when I do the same after a few seconds (this is the reason for my assumption - that inertia would have died by then), I can swipe again.

    How to get continuous swipes working?

    I am currently using MSGesture for gesture recognizer, and creating a new one every time the user starts to swipe on the device.

    my pseudocode

    function handleEverything() { ... myElement.addEventListener("onPointerDown", onPointerDown);

        myElement.style.msTouchAction = "pan-y";

    ... } function onPointerDown(event) { gestureRecognizer = new MSGesture(); gestureRecognizer.target = myElement; if (swipe) { myElement.addEventListener("MSGestureStart", onMSGestureStart); myElement.addEventListener("MSGestureChange", onMSGestureChange); myElement.addEventListener("MSInertiaStart", onMSInertiaStart); } myElement.addEventListener("MSGestureEnd", removeEventListeners); gestureRecognizer.addPointer(event.pointerId); } function onMSGestureChanged() { handleSwipeDelta(); } function onMSInertiaStart() { startInertia(); } function removeEventListeners() { if (gestureRecognizer) { gestureRecognizer.target = null; gestureRecognizer = null; } stopInertia(); myElement.removeEventListener("MSGestureStart", onMSGestureStart); myElement.removeEventListener("MSGestureChange", onMSGestureChange); myElement.removeEventListener("MSInertiaStart", onMSInertiaStart); myElement.removeEventListener("MSGestureEnd", removeEventListeners); }

    I am not sure if there is something that I need to do in addition to this and/or as part of the css for that element.

    Regards, Rv.

    Tuesday, February 25, 2014 2:51 AM

All replies

  • Hi Ravindra,

    I test with my MSGesture code and upload to OneDrive: http://1drv.ms/1mA8rMV, works fine for me, take a look might help you.

    The MSGesture works fine, until I create too much MSGesture object, I would say this is a performance issue and non business with code. To Profile JavaScript code on a local machine is necessary, Analyze memory usage (JavaScript) is also suggested to see if your app use too much memory. The default memory limit is 150MB if higher than this amount, your app might freezing.

    However on a slow move or pan, MSInertiaStart event might not fire.


    MSDN Community Support

    Please remember to "Mark as Answer" the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.

    Wednesday, February 26, 2014 8:42 AM
  • Thanks James, but the problem that I was noticing was while there was already a swipe gesture in its inertial phase, and then when I swiped again I was getting this issue - I am creating a new gesture but that's the guideline provided as per http://msdn.microsoft.com/en-us/library/windows/apps/hh968037.aspx.

    And there were sometimes when I used to get a "InvalidStateError exception" when not creating a new gesture and hence went this way.

    It's weird since that's the recommendation from MS help docs, let me know if I am doing something wrong.

    Regards, Rv.

    Thursday, February 27, 2014 7:30 PM