Skip to content

Commit

Permalink
fix(overlay): onWillDismiss is called as expected
Browse files Browse the repository at this point in the history
  • Loading branch information
manucorporat committed Jun 15, 2017
1 parent 7803998 commit e1747b9
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
16 changes: 10 additions & 6 deletions src/navigation/nav-controller-base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -775,7 +775,10 @@ export class NavControllerBase extends Ion implements NavController {
if (enteringView || leavingView) {
this._zone.run(() => {
// Here, the order is important. WillLeave must be called before WillEnter.
leavingView && this._willLeave(leavingView, !enteringView);
if (leavingView) {
const willUnload = enteringView ? leavingView.index > enteringView.index : true;
this._willLeave(leavingView, willUnload);
}
enteringView && this._willEnter(enteringView);
});
}
Expand Down Expand Up @@ -828,6 +831,8 @@ export class NavControllerBase extends Ion implements NavController {
// ok, cleanup time!! Destroy all of the views that are
// INACTIVE and come after the active view
const activeViewIndex = this._views.indexOf(activeView);
assert(activeViewIndex >= 0, 'active index is invalid');

const views = this._views;
let reorderZIndexes = false;
let view: ViewController;
Expand Down Expand Up @@ -1079,7 +1084,8 @@ export class NavControllerBase extends Ion implements NavController {
view = this.getActive();
}
const views = this._views;
return views[views.indexOf(view) - 1];
const index = views.indexOf(view);
return (index >= 0) ? views[index - 1] : null;
}

first(): ViewController {
Expand All @@ -1089,7 +1095,8 @@ export class NavControllerBase extends Ion implements NavController {

last(): ViewController {
// returns the last page in this nav controller's stack.
return this._views[this._views.length - 1];
const views = this._views;
return views[views.length - 1];
}

indexOf(view: ViewController): number {
Expand All @@ -1101,9 +1108,6 @@ export class NavControllerBase extends Ion implements NavController {
return this._views.length;
}

/**
* Return the stack of views in this NavController.
*/
getViews(): Array<ViewController> {
return this._views;
}
Expand Down
1 change: 0 additions & 1 deletion src/navigation/nav-controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -576,7 +576,6 @@ export abstract class NavController {
*/
abstract length(): number;


/**
* Returns the current stack of views in this nav controller.
* @returns {Array<ViewController>} the stack of view controllers in this nav controller.
Expand Down

0 comments on commit e1747b9

Please sign in to comment.