Skip to content

Commit

Permalink
fix(nav): popTo() uses the new removeView API
Browse files Browse the repository at this point in the history
  • Loading branch information
manucorporat committed Nov 28, 2016
1 parent 16bfb49 commit 6b3e2ed
Showing 1 changed file with 19 additions and 12 deletions.
31 changes: 19 additions & 12 deletions src/navigation/nav-controller-base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,12 +103,18 @@ export class NavControllerBase extends Ion implements NavController {
}

popTo(indexOrViewCtrl: any, opts?: NavOptions, done?: Function): Promise<any> {
const startIndex = isViewController(indexOrViewCtrl) ? this.indexOf(indexOrViewCtrl) : isNumber(indexOrViewCtrl) ? indexOrViewCtrl : -1;
return this._queueTrns({
removeStart: startIndex + 1,
let config: TransitionInstruction = {
removeStart: -1,
removeCount: -1,
opts: opts,
}, done);
opts: opts
};
if (isViewController(indexOrViewCtrl)) {
config.removeView = indexOrViewCtrl;
config.removeStart = 1;
} else if (isNumber(indexOrViewCtrl)) {
config.removeStart = indexOrViewCtrl + 1;
}
return this._queueTrns(config, done);
}

popToRoot(opts?: NavOptions, done?: Function): Promise<any> {
Expand Down Expand Up @@ -138,6 +144,8 @@ export class NavControllerBase extends Ion implements NavController {
removeView(viewController: ViewController, opts?: NavOptions, done?: Function): Promise<any> {
return this._queueTrns({
removeView: viewController,
removeStart: 0,
removeCount: 1,
opts: opts,
}, done);
}
Expand Down Expand Up @@ -295,16 +303,15 @@ export class NavControllerBase extends Ion implements NavController {
const viewsLength = this._views.length;

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);
assert(isPresent(ti.removeStart), 'removeView needs removeStart');
assert(isPresent(ti.removeCount), 'removeView needs removeCount');

let index = this._views.indexOf(ti.removeView);
if (index >= 0) {
ti.removeStart = index;
ti.removeCount = 1;
ti.leavingRequiresTransition = ((ti.removeStart + ti.removeCount) === viewsLength);
ti.removeStart += index;
}

} else if (isPresent(ti.removeStart)) {
}
if (isPresent(ti.removeStart)) {
if (ti.removeStart < 0) {
ti.removeStart = (viewsLength - 1);
}
Expand Down

0 comments on commit 6b3e2ed

Please sign in to comment.