Skip to content

Commit

Permalink
fix(module:pulltorefresh): fix when not use ngmodel worked error (#229)
Browse files Browse the repository at this point in the history
  • Loading branch information
Guoyuanqiang authored and fisherspy committed Jan 9, 2019
1 parent 5482cb2 commit 5a3ba5d
Showing 1 changed file with 24 additions and 8 deletions.
32 changes: 24 additions & 8 deletions components/pull-to-refresh/pull-to-refresh.component.ts
Expand Up @@ -161,7 +161,9 @@ export class PullToRefreshComponent implements ControlValueAccessor {
}
if (distanceY > this.distanceToRefresh) {
this.state.currentState = 'activate';
this._ngModelOnChange(this.state);
if (this._ngModelOnChange) {
this._ngModelOnChange(this.state);
}
}
this.style = {
'-webkit-transform': 'translate3d( 0, ' + distanceY + 'px, 0 )',
Expand Down Expand Up @@ -192,7 +194,9 @@ export class PullToRefreshComponent implements ControlValueAccessor {
distanceY = -(distanceY / (distanceY - this.damping)) * this.damping;
if (Math.abs(distanceY) > this.distanceToRefresh) {
this.state.currentState = 'activate';
this._ngModelOnChange(this.state);
if (this._ngModelOnChange) {
this._ngModelOnChange(this.state);
}
}
this.style = {
'-webkit-transform': 'translate3d( 0, ' + distanceY + 'px, 0 )',
Expand All @@ -213,10 +217,14 @@ export class PullToRefreshComponent implements ControlValueAccessor {
} else {
this.translateY(-this.distanceToRefresh - 1);
}
this._ngModelOnChange(this.state);
if (this._ngModelOnChange) {
this._ngModelOnChange(this.state);
}
setTimeout(() => {
this.state.currentState = 'finish';
this._ngModelOnChange(this.state);
if (this._ngModelOnChange) {
this._ngModelOnChange(this.state);
}
if (this._direction === 'down' || (this._direction === '' && !this._endRreach)) {
this.onRefresh.emit('down');
} else {
Expand All @@ -225,7 +233,9 @@ export class PullToRefreshComponent implements ControlValueAccessor {
}
setTimeout(() => {
this.state.currentState = 'deactivate';
this._ngModelOnChange(this.state);
if (this._ngModelOnChange) {
this._ngModelOnChange(this.state);
}
this.translateY(0);
}, 0);
}, 500);
Expand Down Expand Up @@ -269,7 +279,9 @@ export class PullToRefreshComponent implements ControlValueAccessor {
this._startTime = this._endTime;
if (this.refreshing) {
this.state.currentState = 'release';
this._ngModelOnChange(this.state);
if (this._ngModelOnChange) {
this._ngModelOnChange(this.state);
}
}
setTimeout(() => {
if (this._direction === '') {
Expand All @@ -280,7 +292,9 @@ export class PullToRefreshComponent implements ControlValueAccessor {
}
if (this.refreshing) {
this.state.currentState = 'finish';
this._ngModelOnChange(this.state);
if (this._ngModelOnChange) {
this._ngModelOnChange(this.state);
}
}
}, 500);
} else {
Expand All @@ -290,7 +304,9 @@ export class PullToRefreshComponent implements ControlValueAccessor {
}
if (this.refreshing) {
this.state.currentState = 'finish';
this._ngModelOnChange(this.state);
if (this._ngModelOnChange) {
this._ngModelOnChange(this.state);
}
}
}, 500);
}
Expand Down

0 comments on commit 5a3ba5d

Please sign in to comment.