what is the event name for swipe left in windows 8 html5 javascript app? RRS feed

  • Question

  • i want to capture the event when user swipes from left to right orright to left on a image.And also vertical swpie events such as top to bottom swipe and bottom to up swipe .Are there any event names for this .

    I am using the following statement for just touch/tap event.Is there any similar event for swipe left or swipe right ?


    • Edited by Krrrishna Thursday, August 9, 2012 7:15 AM
    Thursday, August 9, 2012 7:05 AM


All replies

  • I believe that only the WinJS controls such as `WinJS.UI.ListView` actually have "swipe" events.  In other words, there is no built-in swipe event you can use on arbitrary elements.  However, you can achieve the same effect by implementing your own "swipe interpreter" using the `onmousedown` and `onmouseup` events.

    Basically, all you have to do is register an event handler for the `onmousedown` event on the relevant element.  Then, in that event handler, store the coordinates of the cursor and register an event handler for `onmouseup`.  When the `onmouseup` handler fires, check the new cursor coordinates to see if it should be interpreted as a swipe (it will probably take some testing to figure out exactly how to interpret that).  Finally, remove the `onmouseup` handler until the `onmousedown` handler fires again.

    • Proposed as answer by soxley Thursday, August 9, 2012 11:54 AM
    Thursday, August 9, 2012 11:54 AM
  • I will try this and post my reply here.
    Friday, August 10, 2012 5:06 AM
  • This article explains how it's done.

    Please do not follow the approach recommended by soxley. That won't work.


    • Marked as answer by Dino He Friday, August 31, 2012 6:53 AM
    Friday, August 10, 2012 6:06 PM