2

How do I listen for touch move events in the new Microsoft Edge browser in Windows 10?

The Edge browser does not implement JavaScript 'touchstart', 'touchend', and 'touchmove' events. Instead, it uses a new specification to implement 'pointerdown', 'pointerup', and 'pointermove' events, so I listen for those. If I tap the screen I see 'pointerdown' and 'pointerup' events generated, as expected. But if I touch the screen, drag my finger, and break contact with the screen, then I only get a 'pointerdown' event. I was expecting 'pointerdown', followed by a bunch of 'pointermove's, and finally a 'pointerup'. The same thing happens in Internet Explorer 11 as well. How do I get the missing 'pointermove' and 'pointerup' events?

Note that if I let Edge fall back to using 'mousedown', 'mouseup', and 'mousemove' events for touch then dragging my finger will generate a 'mousedown' event, but no 'mousemove's or 'mouseup'.

Bob Arlof
  • 940
  • 10
  • 19
  • 1
    Correct me if I'm wrong, but the answer to the question you pointed to appears to merely be a suggested workaround, not a real answer. Despite their history, it seems unlikely Microsoft would have resorted to MSGesture, which appears to be a Microsoft specific API, as the sole means of handling touch events in JavaScript for Edge and IE 11. However, if you know this to be the case then please confirm. – Bob Arlof Aug 09 '15 at 00:13
  • maybe this helps: put it before ondownevent: `if (navigator.pointerEnabled && evt.pointerId) { evt.target.setPointerCapture(evt.pointerId); } if (evt.isPrimary === undefined || evt.isPrimary) { /* do here moving stuff */ }` – Nina Scholz Aug 09 '15 at 10:28
  • Thanks, Nina, but unfortunately capturing the pointer did not resolve the issue. – Bob Arlof Aug 09 '15 at 14:13
  • 1
    I found the answer, but unfortunately I can only include it here as a comment because of the overzealous busybody who inappropriately closed this question as a duplicate. >:-( THE ANSWER: You need to add style `touch-action: none` to the HTML element that you want to receive the pointer events. Once you do the 'pointermove' and 'pointerup' events will be generated as expected. More info can be found at https://msdn.microsoft.com/en-us/library/dn433244(v=vs.85).aspx#controlling_for_default_touch_handling – Bob Arlof Aug 10 '15 at 20:56
  • touch is a big problem and so does not help here much. – Nina Scholz Aug 10 '15 at 21:05

0 Answers0