Skip to content

Commit 7012734

Browse files
committed
fix(nav): setRoot() and setPages() should not animate
This commit also refactors both methods to avoid deduplicate code,
1 parent c1777c6 commit 7012734

File tree

1 file changed

+15
-8
lines changed

1 file changed

+15
-8
lines changed

src/navigation/nav-controller-base.ts

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -146,19 +146,26 @@ export class NavControllerBase extends Ion implements NavController {
146146
}
147147

148148
setRoot(pageOrViewCtrl: any, params?: any, opts?: NavOptions, done?: Function): Promise<any> {
149-
return this._queueTrns({
150-
insertStart: 0,
151-
insertViews: [convertToView(this._linker, pageOrViewCtrl, params)],
152-
removeStart: 0,
153-
removeCount: -1,
154-
opts: opts
155-
}, done);
149+
let viewControllers = [convertToView(this._linker, pageOrViewCtrl, params)];
150+
return this._setPages(viewControllers, opts, done);
156151
}
157152

158153
setPages(pages: any[], opts?: NavOptions, done?: Function): Promise<any> {
154+
let viewControllers = convertToViews(this._linker, pages);
155+
return this._setPages(viewControllers, opts, done);
156+
}
157+
158+
_setPages(viewControllers: ViewController[], opts?: NavOptions, done?: Function): Promise<any> {
159+
if (isBlank(opts)) {
160+
opts = {};
161+
}
162+
// if animation wasn't set to true then default it to NOT animate
163+
if (opts.animate !== true) {
164+
opts.animate = false;
165+
}
159166
return this._queueTrns({
160167
insertStart: 0,
161-
insertViews: convertToViews(this._linker, pages),
168+
insertViews: viewControllers,
162169
removeStart: 0,
163170
removeCount: -1,
164171
opts: opts

0 commit comments

Comments
 (0)