fix(tapClick): remove mousemove listener

This commit is contained in:
Adam Bradley
2015-12-01 10:18:07 -06:00
parent 1107f69685
commit ae0f66eea8

View File

@ -39,6 +39,13 @@ export class TapClick {
addListener('mousedown', this.mouseDown.bind(this), true); addListener('mousedown', this.mouseDown.bind(this), true);
addListener('mouseup', this.mouseUp.bind(this), true); addListener('mouseup', this.mouseUp.bind(this), true);
}); });
this.pointerMove = function(ev) {
console.log('pointerMove');
if ( hasPointerMoved(POINTER_MOVE_UNTIL_CANCEL, this.startCoord, pointerCoord(ev)) ) {
this.pointerCancel(ev);
}
};
} }
touchStart(ev) { touchStart(ev) {
@ -117,12 +124,6 @@ export class TapClick {
this.activator && this.activator.upAction(); this.activator && this.activator.upAction();
} }
pointerMove(ev) {
if ( hasPointerMoved(POINTER_MOVE_UNTIL_CANCEL, this.startCoord, pointerCoord(ev)) ) {
this.pointerCancel(ev);
}
}
pointerCancel(ev) { pointerCancel(ev) {
console.debug('pointerCancel from', ev.type); console.debug('pointerCancel from', ev.type);
this.activator && this.activator.clearState(); this.activator && this.activator.clearState();
@ -130,11 +131,13 @@ export class TapClick {
} }
moveListeners(shouldAdd) { moveListeners(shouldAdd) {
removeListener(this.usePolyfill ? 'touchmove' : 'mousemove', this.pointerMove);
this.zone.runOutsideAngular(() => { this.zone.runOutsideAngular(() => {
if (shouldAdd) { if (shouldAdd) {
addListener(this.usePolyfill ? 'touchmove' : 'mousemove', this.pointerMove.bind(this)); addListener(this.usePolyfill ? 'touchmove' : 'mousemove', this.pointerMove);
} else { } else {
removeListener(this.usePolyfill ? 'touchmove' : 'mousemove', this.pointerMove.bind(this));
} }
}); });
} }