Skip to content

Commit

Permalink
fix(refresher): only listen for mousemove/touchmove when needed
Browse files Browse the repository at this point in the history
  • Loading branch information
manucorporat committed Jun 21, 2016
1 parent e3ecd3d commit 1a58a41
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions src/components/refresher/refresher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ export class Refresher {
* will automatically go into the `refreshing` state. By default, the pull
* 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`.
Expand Down Expand Up @@ -219,16 +219,23 @@ export class Refresher {
if (ev.touches && ev.touches.length > 1) {
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);
console.debug('Pull-to-refresh, onStart', ev.type, 'y:', coord.y);

this.startY = this.currentY = coord.y;
this.progress = 0;

if (!this.pullMax) {
this.pullMax = (this.pullMin + 60);
}
this.state = STATE_PULLING;
return true;
}

Expand Down

0 comments on commit 1a58a41

Please sign in to comment.