Skip to content

Commit 67ef9eb

Browse files
committed
fix(ptr): fix for kitkat. Fixes #4850
1 parent 9ced132 commit 67ef9eb

File tree

2 files changed

+25
-7
lines changed

2 files changed

+25
-7
lines changed

js/angular/controller/refresherController.js

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,15 @@ IonicModule
4848
startY = Math.floor(e.touches[0].screenY);
4949
}
5050

51+
function handleTouchstart(e) {
52+
e.touches = e.touches || [{
53+
screenX: e.screenX,
54+
screenY: e.screenY
55+
}];
56+
57+
startY = e.touches[0].screenY;
58+
}
59+
5160
function handleTouchend() {
5261
// reset Y
5362
startY = null;
@@ -97,14 +106,16 @@ IonicModule
97106
startY = e.touches[0].screenY;
98107
}
99108

109+
deltaY = e.touches[0].screenY - startY;
110+
111+
// how far have we dragged so far?
100112
// kitkat fix for touchcancel events http://updates.html5rocks.com/2014/05/A-More-Compatible-Smoother-Touch
101-
if (ionic.Platform.isAndroid() && ionic.Platform.version() === 4.4 && scrollParent.scrollTop === 0) {
113+
// Only do this if we're not on crosswalk
114+
if (ionic.Platform.isAndroid() && ionic.Platform.version() === 4.4 && !ionic.Platform.isCrosswalk() && scrollParent.scrollTop === 0 && deltaY > 0) {
102115
isDragging = true;
103116
e.preventDefault();
104117
}
105118

106-
// how far have we dragged so far?
107-
deltaY = e.touches[0].screenY - startY;
108119

109120
// if we've dragged up and back down in to native scroll territory
110121
if (deltaY - dragOffset <= 0 || scrollParent.scrollTop !== 0) {
@@ -257,17 +268,17 @@ IonicModule
257268
}
258269

259270

260-
var touchMoveEvent, touchEndEvent;
271+
var touchStartEvent, touchMoveEvent, touchEndEvent;
261272
if (window.navigator.pointerEnabled) {
262-
//touchStartEvent = 'pointerdown';
273+
touchStartEvent = 'pointerdown';
263274
touchMoveEvent = 'pointermove';
264275
touchEndEvent = 'pointerup';
265276
} else if (window.navigator.msPointerEnabled) {
266-
//touchStartEvent = 'MSPointerDown';
277+
touchStartEvent = 'MSPointerDown';
267278
touchMoveEvent = 'MSPointerMove';
268279
touchEndEvent = 'MSPointerUp';
269280
} else {
270-
//touchStartEvent = 'touchstart';
281+
touchStartEvent = 'touchstart';
271282
touchMoveEvent = 'touchmove';
272283
touchEndEvent = 'touchend';
273284
}
@@ -282,6 +293,7 @@ IonicModule
282293
}
283294

284295

296+
ionic.on(touchStartEvent, handleTouchstart, scrollChild);
285297
ionic.on(touchMoveEvent, handleTouchmove, scrollChild);
286298
ionic.on(touchEndEvent, handleTouchend, scrollChild);
287299
ionic.on('mousedown', handleMousedown, scrollChild);
@@ -294,6 +306,7 @@ IonicModule
294306
};
295307

296308
function destroy() {
309+
ionic.off(touchStartEvent, handleTouchstart, scrollChild);
297310
ionic.off(touchMoveEvent, handleTouchmove, scrollChild);
298311
ionic.off(touchEndEvent, handleTouchend, scrollChild);
299312
ionic.off('mousedown', handleMousedown, scrollChild);

js/utils/platform.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
var ANDROID = 'android';
1212
var WINDOWS_PHONE = 'windowsphone';
1313
var EDGE = 'edge';
14+
var CROSSWALK = 'crosswalk';
1415
var requestAnimationFrame = ionic.requestAnimationFrame;
1516

1617
/**
@@ -239,6 +240,10 @@
239240
return self.is(EDGE);
240241
},
241242

243+
isCrosswalk: function() {
244+
return self.is(CROSSWALK);
245+
},
246+
242247
/**
243248
* @ngdoc method
244249
* @name ionic.Platform#platform

0 commit comments

Comments
 (0)