Skip to content

Commit 5ff7072

Browse files
committed
fix(nav): async removing for views
1 parent 75186b4 commit 5ff7072

File tree

2 files changed

+19
-5
lines changed

2 files changed

+19
-5
lines changed

src/navigation/nav-controller-base.ts

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,10 @@ export class NavControllerBase extends Ion implements NavController {
136136
}
137137

138138
removeView(viewController: ViewController, opts?: NavOptions, done?: Function): Promise<any> {
139-
return this.remove(this.indexOf(viewController), 1, opts, done);
139+
return this._queueTrns({
140+
removeView: viewController,
141+
opts: opts,
142+
}, done);
140143
}
141144

142145
setRoot(pageOrViewCtrl: any, params?: any, opts?: NavOptions, done?: Function): Promise<any> {
@@ -291,7 +294,17 @@ export class NavControllerBase extends Ion implements NavController {
291294
}
292295
const viewsLength = this._views.length;
293296

294-
if (isPresent(ti.removeStart)) {
297+
if (isPresent(ti.removeView)) {
298+
assert(!isPresent(ti.removeStart), 'removeView and removeIndex can not be enabled at the same time');
299+
let index = this._views.indexOf(ti.removeView);
300+
301+
if (index >= 0) {
302+
ti.removeStart = index;
303+
ti.removeCount = 1;
304+
ti.leavingRequiresTransition = ((ti.removeStart + ti.removeCount) === viewsLength);
305+
}
306+
307+
} else if (isPresent(ti.removeStart)) {
295308
if (ti.removeStart < 0) {
296309
ti.removeStart = (viewsLength - 1);
297310
}
@@ -347,6 +360,7 @@ export class NavControllerBase extends Ion implements NavController {
347360
if (isPresent(removeStart)) {
348361
assert(removeStart >= 0, 'removeStart can not be negative');
349362
assert(ti.removeCount >= 0, 'removeCount can not be negative');
363+
350364
destroyQueue = [];
351365
for (i = 0; i < ti.removeCount; i++) {
352366
view = this._views[i + removeStart];
@@ -580,6 +594,8 @@ export class NavControllerBase extends Ion implements NavController {
580594
}
581595

582596
_trnsStart(transition: Transition, enteringView: ViewController, leavingView: ViewController, opts: NavOptions, resolve: TransitionResolveFn) {
597+
assert(this.isTransitioning(), 'isTransitioning() has to be true');
598+
583599
this._trnsId = null;
584600

585601
// set the correct zIndex for the entering and leaving views
@@ -624,9 +640,6 @@ export class NavControllerBase extends Ion implements NavController {
624640
// get the set duration of this transition
625641
const duration = transition.getDuration();
626642

627-
// set that this nav is actively transitioning
628-
this.setTransitioning(true);
629-
630643
if (transition.isRoot()) {
631644
// this is the top most, or only active transition, so disable the app
632645
// add XXms to the duration the app is disabled when the keyboard is open

src/navigation/nav-util.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,7 @@ export interface TransitionInstruction {
177177
opts: NavOptions;
178178
insertStart?: number;
179179
insertViews?: ViewController[];
180+
removeView?: ViewController;
180181
removeStart?: number;
181182
removeCount?: number;
182183
resolve?: TransitionResolveFn;

0 commit comments

Comments
 (0)