diff --git a/ionic/animations/animation.ts b/ionic/animations/animation.ts index 2d0bd93e58..4d221f8170 100644 --- a/ionic/animations/animation.ts +++ b/ionic/animations/animation.ts @@ -23,13 +23,14 @@ export class Animation { private _fFns: Function[]; private _fOnceFns: Function[]; private _wChg: boolean = false; - private _rv: boolean; + private _rv: boolean = false; private _unregTrans: Function; private _tmr: number; private _lastUpd: number = 0; - public isPlaying: boolean; - public hasTween: boolean; + public isPlaying: boolean = false; + public hasTween: boolean = false; + public hasCompleted: boolean = false; constructor(ele?: any, opts: AnimationOptions = {}) { this._reset(); @@ -57,9 +58,6 @@ export class Animation { this._fOnceFns = []; this._clearAsync(); - - this.isPlaying = this.hasTween = this._rv = false; - this._easing = this._dur = null; } element(ele: any): Animation { @@ -687,13 +685,14 @@ export class Animation { _onFinish(hasCompleted: boolean) { this.isPlaying = false; + this.hasCompleted = hasCompleted; var i: number; for (i = 0; i < this._fFns.length; i++) { - this._fFns[i](hasCompleted); + this._fFns[i](this); } for (i = 0; i < this._fOnceFns.length; i++) { - this._fOnceFns[i](hasCompleted); + this._fOnceFns[i](this); } this._fOnceFns = []; } diff --git a/ionic/components/app/test/animations/index.ts b/ionic/components/app/test/animations/index.ts index d2b532b74f..d0ce9de8a8 100644 --- a/ionic/components/app/test/animations/index.ts +++ b/ionic/components/app/test/animations/index.ts @@ -22,6 +22,35 @@ class E2EPage { a.easing(this.easing); a.play(); } + + memoryCheck() { + let self = this; + let count = 0; + + function play() { + count++; + if (count >= 100) { + console.log('Play done'); + return; + } + + console.log('Play', count); + + let a = new Animation('.green'); + a.fromTo('translateX', '0px', '200px'); + a.duration(self.duration); + a.easing(self.easing); + a.onFinish((animation) => { + setTimeout(() => { + play(); + }, 100); + animation.destroy(); + }); + a.play(); + } + + play(); + } } diff --git a/ionic/components/app/test/animations/main.html b/ionic/components/app/test/animations/main.html index 973af82a0c..92b87cb349 100644 --- a/ionic/components/app/test/animations/main.html +++ b/ionic/components/app/test/animations/main.html @@ -28,6 +28,10 @@ + + diff --git a/ionic/components/nav/nav-controller.ts b/ionic/components/nav/nav-controller.ts index 8d30071acb..3516e4156a 100644 --- a/ionic/components/nav/nav-controller.ts +++ b/ionic/components/nav/nav-controller.ts @@ -1081,13 +1081,13 @@ export class NavController extends Ion { } // create a callback for when the animation is done - transAnimation.onFinish((hasCompleted: boolean) => { + transAnimation.onFinish((trans: Transition) => { // transition animation has ended // destroy the animation and it's element references - transAnimation.destroy(); + trans.destroy(); - this._afterTrans(enteringView, leavingView, opts, hasCompleted, done); + this._afterTrans(enteringView, leavingView, opts, trans.hasCompleted, done); }); // cool, let's do this, start the transition