Skip to content

Commit 1f43278

Browse files
committed
feat(refresher): handle pointer events
1 parent 920db1c commit 1f43278

File tree

1 file changed

+25
-4
lines changed

1 file changed

+25
-4
lines changed

Diff for: js/angular/controller/refresherController.js

+25-4
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,11 @@ IonicModule
8383
screenY: e.screenY
8484
}];
8585

86+
// Force mouse events to have had a down event first
87+
if(!startY && e.type == 'mousemove') {
88+
return;
89+
}
90+
8691
// if multitouch or regular scroll event, get out immediately
8792
if (!canOverscroll || e.touches.length > 1) {
8893
return;
@@ -252,6 +257,21 @@ IonicModule
252257
}
253258

254259

260+
var touchStartEvent, touchMoveEvent, touchEndEvent;
261+
if (window.navigator.pointerEnabled) {
262+
touchStartEvent = 'pointerdown';
263+
touchMoveEvent = 'pointermove';
264+
touchEndEvent = 'pointerup';
265+
} else if (window.navigator.msPointerEnabled) {
266+
touchStartEvent = 'MSPointerDown';
267+
touchMoveEvent = 'MSPointerMove';
268+
touchEndEvent = 'MSPointerUp';
269+
} else {
270+
touchStartEvent = 'touchstart';
271+
touchMoveEvent = 'touchmove';
272+
touchEndEvent = 'touchend';
273+
}
274+
255275
self.init = function() {
256276
scrollParent = $element.parent().parent()[0];
257277
scrollChild = $element.parent()[0];
@@ -261,8 +281,9 @@ IonicModule
261281
throw new Error('Refresher must be immediate child of ion-content or ion-scroll');
262282
}
263283

264-
ionic.on('touchmove', handleTouchmove, scrollChild);
265-
ionic.on('touchend', handleTouchend, scrollChild);
284+
285+
ionic.on(touchMoveEvent, handleTouchmove, scrollChild);
286+
ionic.on(touchEndEvent, handleTouchend, scrollChild);
266287
ionic.on('mousedown', handleMousedown, scrollChild);
267288
ionic.on('mousemove', handleTouchmove, scrollChild);
268289
ionic.on('mouseup', handleTouchend, scrollChild);
@@ -273,8 +294,8 @@ IonicModule
273294
};
274295

275296
function destroy() {
276-
ionic.off('touchmove', handleTouchmove, scrollChild);
277-
ionic.off('touchend', handleTouchend, scrollChild);
297+
ionic.off(touchMoveEvent, handleTouchmove, scrollChild);
298+
ionic.off(touchEndEvent, handleTouchend, scrollChild);
278299
ionic.off('mousedown', handleMousedown, scrollChild);
279300
ionic.off('mousemove', handleTouchmove, scrollChild);
280301
ionic.off('mouseup', handleTouchend, scrollChild);

0 commit comments

Comments
 (0)