Skip to content

Commit

Permalink
fix(loading): clear timeout if dismissed before timeout fires
Browse files Browse the repository at this point in the history
  • Loading branch information
jgw96 authored and adamdbradley committed Jul 7, 2016
1 parent 6c6254c commit 5bbe31a
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/components/loading/loading-component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ export class LoadingCmp {
private d: any;
private id: number;
private showSpinner: boolean;
private durationTimeout: number;

constructor(
private _viewCtrl: ViewController,
Expand Down Expand Up @@ -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<any> {
if (this.durationTimeout) {
clearTimeout(this.durationTimeout);
}
return this._viewCtrl.dismiss(null, role);
}
}
Expand Down

0 comments on commit 5bbe31a

Please sign in to comment.