Skip to content

Commit 5d874b5

Browse files
committed
The timer should only be initialized if the spinner is not visible. Fixes #89
1 parent c7b02d9 commit 5d874b5

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

src/lib/components/ng-http-loader.component.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -114,14 +114,17 @@ export class NgHttpLoaderComponent implements OnDestroy, OnInit {
114114

115115
private handleMinDuration(hasPendingRequests: boolean): Observable<number> {
116116
if (hasPendingRequests || !this.minDuration) {
117-
this.startTime = Date.now();
117+
if (this.shouldInitStartTime()) {
118+
this.startTime = Date.now();
119+
}
118120

119121
return timer(0);
120122
}
121123

122-
const timerObservable = timer(this.minDuration - (Date.now() - this.startTime));
123-
this.startTime = null;
124+
return timer(this.minDuration - (Date.now() - this.startTime));
125+
}
124126

125-
return timerObservable;
127+
private shouldInitStartTime(): boolean {
128+
return !this.isSpinnerVisible;
126129
}
127130
}

0 commit comments

Comments
 (0)