fix(loading): fix loading events

This commit is contained in:
Adam Bradley
2017-08-03 16:04:27 -05:00
parent 3e9bbb6531
commit f1b60c61c3
2 changed files with 14 additions and 12 deletions

View File

@ -46,7 +46,7 @@ export class LoadingController implements IonicControllerApi {
@Listen('body:ionLoadingDidLoad') @Listen('body:ionLoadingDidLoad')
viewDidLoad(ev: LoadingEvent) { viewDidLoad(ev: LoadingEvent) {
const loading = ev.loading; const loading = ev.detail.loading;
const loadingResolve = this.loadingResolves[loading.id]; const loadingResolve = this.loadingResolves[loading.id];
if (loadingResolve) { if (loadingResolve) {
loadingResolve(loading); loadingResolve(loading);
@ -57,13 +57,13 @@ export class LoadingController implements IonicControllerApi {
@Listen('body:ionLoadingWillPresent') @Listen('body:ionLoadingWillPresent')
willPresent(ev: LoadingEvent) { willPresent(ev: LoadingEvent) {
this.loadings.push(ev.loading); this.loadings.push(ev.detail.loading);
} }
@Listen('body:ionLoadingWillDismiss, body:ionLoadingDidUnload') @Listen('body:ionLoadingWillDismiss, body:ionLoadingDidUnload')
willDismiss(ev: LoadingEvent) { willDismiss(ev: LoadingEvent) {
const index = this.loadings.indexOf(ev.loading); const index = this.loadings.indexOf(ev.detail.loading);
if (index > -1) { if (index > -1) {
this.loadings.splice(index, 1); this.loadings.splice(index, 1);
} }

View File

@ -57,7 +57,7 @@ export class Loading {
if (this.showSpinner === null || this.showSpinner === undefined) { if (this.showSpinner === null || this.showSpinner === undefined) {
this.showSpinner = !!(this.spinner && this.spinner !== 'hide'); this.showSpinner = !!(this.spinner && this.spinner !== 'hide');
} }
this.ionLoadingDidLoad.emit({ loading: this } as LoadingEvent); this.ionLoadingDidLoad.emit({ loading: this });
} }
ionViewDidEnter() { ionViewDidEnter() {
@ -70,7 +70,7 @@ export class Loading {
this.durationTimeout = setTimeout(() => this.dismiss(), this.duration); this.durationTimeout = setTimeout(() => this.dismiss(), this.duration);
} }
this.ionLoadingDidPresent.emit({ loading: this } as LoadingEvent); this.ionLoadingDidPresent.emit({ loading: this });
} }
present() { present() {
@ -85,7 +85,7 @@ export class Loading {
this.animation = null; this.animation = null;
} }
this.ionLoadingWillPresent.emit({ loading: this } as LoadingEvent); this.ionLoadingWillPresent.emit({ loading: this });
// get the user's animation fn if one was provided // get the user's animation fn if one was provided
let animationBuilder = this.enterAnimation; let animationBuilder = this.enterAnimation;
@ -121,7 +121,7 @@ export class Loading {
return Ionic.controller('animation').then(Animation => { return Ionic.controller('animation').then(Animation => {
return new Promise(resolve => { return new Promise(resolve => {
this.ionLoadingWillDismiss.emit({ loading: this } as LoadingEvent); this.ionLoadingWillDismiss.emit({ loading: this });
// get the user's animation fn if one was provided // get the user's animation fn if one was provided
let animationBuilder = this.exitAnimation; let animationBuilder = this.exitAnimation;
@ -137,7 +137,7 @@ export class Loading {
this.animation = animationBuilder(Animation, this.el); this.animation = animationBuilder(Animation, this.el);
this.animation.onFinish((a: any) => { this.animation.onFinish((a: any) => {
a.destroy(); a.destroy();
this.ionLoadingDidDismiss.emit({ loading: this } as LoadingEvent); this.ionLoadingDidDismiss.emit({ loading: this });
Core.dom.write(() => { Core.dom.write(() => {
this.el.parentNode.removeChild(this.el); this.el.parentNode.removeChild(this.el);
@ -151,7 +151,7 @@ export class Loading {
} }
ionViewDidUnload() { ionViewDidUnload() {
this.ionLoadingDidUnload.emit({ loading: this }as LoadingEvent); this.ionLoadingDidUnload.emit({ loading: this });
} }
render() { render() {
@ -205,6 +205,8 @@ export interface LoadingOptions {
} }
export interface LoadingEvent { export interface LoadingEvent extends Event {
loading: Loading; detail: {
} loading: Loading;
}
}