Skip to content

Commit

Permalink
fix(refresher): adds threshold
Browse files Browse the repository at this point in the history
  • Loading branch information
manucorporat committed May 11, 2018
1 parent b06c65f commit 34ae904
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 19 deletions.
30 changes: 12 additions & 18 deletions core/src/components/refresher/refresher.tsx
Expand Up @@ -26,7 +26,6 @@ export class Refresher {

private appliedStyles = false;
private didStart = false;
private gestureConfig: any;
private progress = 0;
private scrollEl: HTMLElement | null = null;

Expand Down Expand Up @@ -94,22 +93,6 @@ export class Refresher {
*/
@Event() ionStart!: EventEmitter<void>;

componentWillLoad() {
this.gestureConfig = {
'canStart': this.canStart.bind(this),
'onStart': this.onStart.bind(this),
'onMove': this.onMove.bind(this),
'onEnd': this.onEnd.bind(this),
'gestureName': 'refresher',
'gesturePriority': 10,
'type': 'pan',
'passive': false,
'direction': 'y',
'threshold': 0,
'attachTo': this.el.closest('ion-content')
};
}

componentDidLoad() {
if (this.el.getAttribute('slot') !== 'fixed') {
console.error('Make sure you use: <ion-refresher slot="fixed">');
Expand Down Expand Up @@ -241,6 +224,7 @@ export class Refresher {
}

// prevent native scroll events
console.log('preventDefault');
ev.preventDefault();

// the refresher is actively pulling at this point
Expand Down Expand Up @@ -360,7 +344,17 @@ export class Refresher {
}

render() {
return <ion-gesture {...this.gestureConfig}
return <ion-gesture
canStart={this.canStart.bind(this)}
onStart={this.onStart.bind(this)}
onMove={this.onMove.bind(this)}
onEnd={this.onEnd.bind(this)}
gestureName="refresher"
gesturePriority={10}
passive={false}
direction="y"
threshold={5}
attachTo={this.el.closest('ion-content') as any}
disabled={this.disabled}>
<slot></slot>
</ion-gesture>;
Expand Down
2 changes: 1 addition & 1 deletion core/src/components/refresher/test/basic/index.html
Expand Up @@ -54,7 +54,7 @@
function render() {
let html = '';
for(let item of items) {
html += `<ion-item>${item}</ion-item>`;
html += `<ion-item button>${item}</ion-item>`;
}
list.innerHTML = html;
}
Expand Down

0 comments on commit 34ae904

Please sign in to comment.