fix(refresher): only listen for mousemove/touchmove when needed

This commit is contained in:
Manu Mtz.-Almeida
2016-06-21 17:26:07 +02:00
parent e3ecd3d05b
commit 1a58a41cf9

View File

@ -151,7 +151,7 @@ export class Refresher {
* will automatically go into the `refreshing` state. By default, the pull * will automatically go into the `refreshing` state. By default, the pull
* maximum will be the result of `pullMin + 60`. * maximum will be the result of `pullMin + 60`.
*/ */
@Input() pullMax: number = null; @Input() pullMax: number = this.pullMin + 60;
/** /**
* @input {number} How many milliseconds it takes to close the refresher. Default is `280`. * @input {number} How many milliseconds it takes to close the refresher. Default is `280`.
@ -219,16 +219,23 @@ export class Refresher {
if (ev.touches && ev.touches.length > 1) { if (ev.touches && ev.touches.length > 1) {
return false; return false;
} }
if (this.state !== STATE_INACTIVE) {
return false;
}
let scrollHostScrollTop = this._content.getContentDimensions().scrollTop;
// if the scrollTop is greater than zero then it's
// not possible to pull the content down yet
if (scrollHostScrollTop > 0) {
return false;
}
let coord = pointerCoord(ev); let coord = pointerCoord(ev);
console.debug('Pull-to-refresh, onStart', ev.type, 'y:', coord.y); console.debug('Pull-to-refresh, onStart', ev.type, 'y:', coord.y);
this.startY = this.currentY = coord.y; this.startY = this.currentY = coord.y;
this.progress = 0; this.progress = 0;
this.state = STATE_PULLING;
if (!this.pullMax) {
this.pullMax = (this.pullMin + 60);
}
return true; return true;
} }