Skip to content

Commit

Permalink
fix(gestures): On KitKat preventDefault on touchstart
Browse files Browse the repository at this point in the history
  • Loading branch information
MartinMa committed Jan 5, 2016
1 parent f44fad0 commit 7345c1f
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions js/utils/gestures.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 7345c1f

Please sign in to comment.