Skip to content

Commit

Permalink
feat(refresher): handle pointer events
Browse files Browse the repository at this point in the history
  • Loading branch information
mlynch committed Dec 17, 2015
1 parent 920db1c commit 1f43278
Showing 1 changed file with 25 additions and 4 deletions.
29 changes: 25 additions & 4 deletions js/angular/controller/refresherController.js
Expand Up @@ -83,6 +83,11 @@ IonicModule
screenY: e.screenY
}];

// Force mouse events to have had a down event first
if(!startY && e.type == 'mousemove') {
return;
}

// if multitouch or regular scroll event, get out immediately
if (!canOverscroll || e.touches.length > 1) {
return;
Expand Down Expand Up @@ -252,6 +257,21 @@ IonicModule
}


var touchStartEvent, touchMoveEvent, touchEndEvent;
if (window.navigator.pointerEnabled) {
touchStartEvent = 'pointerdown';
touchMoveEvent = 'pointermove';
touchEndEvent = 'pointerup';
} else if (window.navigator.msPointerEnabled) {
touchStartEvent = 'MSPointerDown';
touchMoveEvent = 'MSPointerMove';
touchEndEvent = 'MSPointerUp';
} else {
touchStartEvent = 'touchstart';
touchMoveEvent = 'touchmove';
touchEndEvent = 'touchend';
}

self.init = function() {
scrollParent = $element.parent().parent()[0];
scrollChild = $element.parent()[0];
Expand All @@ -261,8 +281,9 @@ IonicModule
throw new Error('Refresher must be immediate child of ion-content or ion-scroll');
}

ionic.on('touchmove', handleTouchmove, scrollChild);
ionic.on('touchend', handleTouchend, scrollChild);

ionic.on(touchMoveEvent, handleTouchmove, scrollChild);
ionic.on(touchEndEvent, handleTouchend, scrollChild);
ionic.on('mousedown', handleMousedown, scrollChild);
ionic.on('mousemove', handleTouchmove, scrollChild);
ionic.on('mouseup', handleTouchend, scrollChild);
Expand All @@ -273,8 +294,8 @@ IonicModule
};

function destroy() {
ionic.off('touchmove', handleTouchmove, scrollChild);
ionic.off('touchend', handleTouchend, scrollChild);
ionic.off(touchMoveEvent, handleTouchmove, scrollChild);
ionic.off(touchEndEvent, handleTouchend, scrollChild);
ionic.off('mousedown', handleMousedown, scrollChild);
ionic.off('mousemove', handleTouchmove, scrollChild);
ionic.off('mouseup', handleTouchend, scrollChild);
Expand Down

0 comments on commit 1f43278

Please sign in to comment.