Skip to content

Commit 1a58a41

Browse files
committed
fix(refresher): only listen for mousemove/touchmove when needed
1 parent e3ecd3d commit 1a58a41

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

src/components/refresher/refresher.ts

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ export class Refresher {
151151
* will automatically go into the `refreshing` state. By default, the pull
152152
* maximum will be the result of `pullMin + 60`.
153153
*/
154-
@Input() pullMax: number = null;
154+
@Input() pullMax: number = this.pullMin + 60;
155155

156156
/**
157157
* @input {number} How many milliseconds it takes to close the refresher. Default is `280`.
@@ -219,16 +219,23 @@ export class Refresher {
219219
if (ev.touches && ev.touches.length > 1) {
220220
return false;
221221
}
222+
if (this.state !== STATE_INACTIVE) {
223+
return false;
224+
}
225+
226+
let scrollHostScrollTop = this._content.getContentDimensions().scrollTop;
227+
// if the scrollTop is greater than zero then it's
228+
// not possible to pull the content down yet
229+
if (scrollHostScrollTop > 0) {
230+
return false;
231+
}
222232

223233
let coord = pointerCoord(ev);
224234
console.debug('Pull-to-refresh, onStart', ev.type, 'y:', coord.y);
225235

226236
this.startY = this.currentY = coord.y;
227237
this.progress = 0;
228-
229-
if (!this.pullMax) {
230-
this.pullMax = (this.pullMin + 60);
231-
}
238+
this.state = STATE_PULLING;
232239
return true;
233240
}
234241

0 commit comments

Comments
 (0)