From 7345c1f371b7d0874550b1f3050abd5fc625ab36 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20M=C3=A4dler?= Date: Tue, 5 Jan 2016 16:44:41 +0100 Subject: [PATCH] fix(gestures): On KitKat preventDefault on touchstart Fixes #3695 --- js/utils/gestures.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/js/utils/gestures.js b/js/utils/gestures.js index c05bc2b0e7a..9ed5f7cc4c8 100644 --- a/js/utils/gestures.js +++ b/js/utils/gestures.js @@ -304,6 +304,15 @@ else if(!touch_triggered) { count_touches = sourceEventType.match(/up/) ? 0 : 1; } + + // kitkat fix for touchcancel events http://updates.html5rocks.com/2014/05/A-More-Compatible-Smoother-Touch + // Only do this if we're not on crosswalk + if (sourceEventType === 'touchstart' && + ionic.Platform.isAndroid() && + ionic.Platform.version() === 4.4 && + !ionic.Platform.isCrosswalk()) { + ev.preventDefault(); + } // if we are in a end event, but when we remove one touch and // we still have enough, set eventType to move @@ -1171,8 +1180,7 @@ } else if (!this.preventedFirstMove && ev.srcEvent.type == 'touchmove') { // Prevent gestures that are not intended for this event handler from firing subsequent times - if (inst.options.prevent_default_directions.length > 0 - && inst.options.prevent_default_directions.indexOf(ev.direction) != -1) { + if (inst.options.prevent_default_directions.indexOf(ev.direction) != -1) { ev.srcEvent.preventDefault(); } this.preventedFirstMove = true;