Skip to content

Commit 5bbe31a

Browse files
jgw96adamdbradley
authored andcommitted
fix(loading): clear timeout if dismissed before timeout fires
1 parent 6c6254c commit 5bbe31a

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/components/loading/loading-component.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ export class LoadingCmp {
3535
private d: any;
3636
private id: number;
3737
private showSpinner: boolean;
38+
private durationTimeout: number;
3839

3940
constructor(
4041
private _viewCtrl: ViewController,
@@ -70,10 +71,13 @@ export class LoadingCmp {
7071
}
7172

7273
// If there is a duration, dismiss after that amount of time
73-
this.d.duration ? setTimeout(() => this.dismiss('backdrop'), this.d.duration) : null;
74+
this.d.duration ? this.durationTimeout = setTimeout(() => this.dismiss('backdrop'), this.d.duration) : null;
7475
}
7576

7677
dismiss(role: any): Promise<any> {
78+
if (this.durationTimeout) {
79+
clearTimeout(this.durationTimeout);
80+
}
7781
return this._viewCtrl.dismiss(null, role);
7882
}
7983
}

0 commit comments

Comments
 (0)