0
votes

I'm currently building a touch enabled slider widget intended for multiple browsers. So, I have listeners for touchstart, touchend, touchmove, mousedown, mousemove, and mousedown. It works great except on Mobile Safari.

If I long press on my target, a mousemove event fires with the coordinates of the previous touch causing jitter.

How do I prevent or filter out this mousemove event without causing problems with desktop interaction?

2

2 Answers

0
votes

Have you considered using Swipe JS ? http://swipejs.com/

0
votes

The sequence of events for a long press in mobile safari is touchstart, mousemove, touchend. This is different from a valid mouse move (mousedown, mousemove, mouseup) and a valid touch (touchstart, touchmove, touchend). If you call prevent default for all the valid events, you won't get extra notifications. So, if you track that the slider is moving with a mouse independently from moving in response to touch, the mousemove occurs outside of a normal sequence and can be safely ignored.