From 5bbe31a69f6ea9489c4d6a8b0f8bc7edbac0e234 Mon Sep 17 00:00:00 2001 From: Justin Willis Date: Thu, 7 Jul 2016 13:00:12 -0500 Subject: [PATCH] fix(loading): clear timeout if dismissed before timeout fires --- src/components/loading/loading-component.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/components/loading/loading-component.ts b/src/components/loading/loading-component.ts index ab294342b8..6e5302fc87 100644 --- a/src/components/loading/loading-component.ts +++ b/src/components/loading/loading-component.ts @@ -35,6 +35,7 @@ export class LoadingCmp { private d: any; private id: number; private showSpinner: boolean; + private durationTimeout: number; constructor( private _viewCtrl: ViewController, @@ -70,10 +71,13 @@ export class LoadingCmp { } // 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 { + if (this.durationTimeout) { + clearTimeout(this.durationTimeout); + } return this._viewCtrl.dismiss(null, role); } }