mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-22 05:21:52 +08:00
fix(loading): clear timeout if dismissed before timeout fires
This commit is contained in:

committed by
Adam Bradley

parent
6c6254c213
commit
5bbe31a69f
@ -35,6 +35,7 @@ export class LoadingCmp {
|
|||||||
private d: any;
|
private d: any;
|
||||||
private id: number;
|
private id: number;
|
||||||
private showSpinner: boolean;
|
private showSpinner: boolean;
|
||||||
|
private durationTimeout: number;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private _viewCtrl: ViewController,
|
private _viewCtrl: ViewController,
|
||||||
@ -70,10 +71,13 @@ export class LoadingCmp {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// If there is a duration, dismiss after that amount of time
|
// If there is a duration, dismiss after that amount of time
|
||||||
this.d.duration ? setTimeout(() => this.dismiss('backdrop'), this.d.duration) : null;
|
this.d.duration ? this.durationTimeout = setTimeout(() => this.dismiss('backdrop'), this.d.duration) : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
dismiss(role: any): Promise<any> {
|
dismiss(role: any): Promise<any> {
|
||||||
|
if (this.durationTimeout) {
|
||||||
|
clearTimeout(this.durationTimeout);
|
||||||
|
}
|
||||||
return this._viewCtrl.dismiss(null, role);
|
return this._viewCtrl.dismiss(null, role);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user