Touchcancel will always be fired unless you prevent default in touchmove
, because the browser must take control of the pan and zoom actions almost immediately. Your best bet is to swich to the Pointer Events interface using the touch-action
CSS attribute accordingly, this gives you more control since pointermove
can avoid pointercancel
, depending on your touch-action
CSS property applied to the relevant object.
The touchcancel event is fired when a touch point has been disrupted
in an implementation-specific manner (for example, too many touch
points are created).
When using Pointer events, touch-action: pan-y
will allow the browser to perform regular vertical scrolling, and won't fire pointercancel
(the touchcancel
equivalent) when the gesture is performed vertically. Touch-action: none
is the equivalent to calling event.preventDefault()
as it will neither scroll nor zoom nor apply any of the default browser actions.
The pointercancel event is fired when the browser determines that
there are unlikely to be any more pointer events, or if after the
pointerdown event is fired, the pointer is then used to manipulate the
viewport by panning, zooming, or scrolling.
Check out this jQuery plugin that handles horizontal swipe events with both Touch and Pointer interfaces and explains the differences between them in more detail.