From 5ff7072242bb36cf51a0862384be635c04bf1658 Mon Sep 17 00:00:00 2001 From: "Manu Mtz.-Almeida" Date: Sat, 26 Nov 2016 18:33:06 +0100 Subject: [PATCH] fix(nav): async removing for views --- src/navigation/nav-controller-base.ts | 23 ++++++++++++++++++----- src/navigation/nav-util.ts | 1 + 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/src/navigation/nav-controller-base.ts b/src/navigation/nav-controller-base.ts index 16288c9b6c7..ddbb9a30b25 100644 --- a/src/navigation/nav-controller-base.ts +++ b/src/navigation/nav-controller-base.ts @@ -136,7 +136,10 @@ export class NavControllerBase extends Ion implements NavController { } removeView(viewController: ViewController, opts?: NavOptions, done?: Function): Promise { - return this.remove(this.indexOf(viewController), 1, opts, done); + return this._queueTrns({ + removeView: viewController, + opts: opts, + }, done); } setRoot(pageOrViewCtrl: any, params?: any, opts?: NavOptions, done?: Function): Promise { @@ -291,7 +294,17 @@ export class NavControllerBase extends Ion implements NavController { } const viewsLength = this._views.length; - if (isPresent(ti.removeStart)) { + if (isPresent(ti.removeView)) { + assert(!isPresent(ti.removeStart), 'removeView and removeIndex can not be enabled at the same time'); + let index = this._views.indexOf(ti.removeView); + + if (index >= 0) { + ti.removeStart = index; + ti.removeCount = 1; + ti.leavingRequiresTransition = ((ti.removeStart + ti.removeCount) === viewsLength); + } + + } else if (isPresent(ti.removeStart)) { if (ti.removeStart < 0) { ti.removeStart = (viewsLength - 1); } @@ -347,6 +360,7 @@ export class NavControllerBase extends Ion implements NavController { if (isPresent(removeStart)) { assert(removeStart >= 0, 'removeStart can not be negative'); assert(ti.removeCount >= 0, 'removeCount can not be negative'); + destroyQueue = []; for (i = 0; i < ti.removeCount; i++) { view = this._views[i + removeStart]; @@ -580,6 +594,8 @@ export class NavControllerBase extends Ion implements NavController { } _trnsStart(transition: Transition, enteringView: ViewController, leavingView: ViewController, opts: NavOptions, resolve: TransitionResolveFn) { + assert(this.isTransitioning(), 'isTransitioning() has to be true'); + this._trnsId = null; // set the correct zIndex for the entering and leaving views @@ -624,9 +640,6 @@ export class NavControllerBase extends Ion implements NavController { // get the set duration of this transition const duration = transition.getDuration(); - // set that this nav is actively transitioning - this.setTransitioning(true); - if (transition.isRoot()) { // this is the top most, or only active transition, so disable the app // add XXms to the duration the app is disabled when the keyboard is open diff --git a/src/navigation/nav-util.ts b/src/navigation/nav-util.ts index b5072cfc8fe..da600071677 100644 --- a/src/navigation/nav-util.ts +++ b/src/navigation/nav-util.ts @@ -177,6 +177,7 @@ export interface TransitionInstruction { opts: NavOptions; insertStart?: number; insertViews?: ViewController[]; + removeView?: ViewController; removeStart?: number; removeCount?: number; resolve?: TransitionResolveFn;