From f5f4169db01f6c9a7ef24249a66440eff3f14e9a Mon Sep 17 00:00:00 2001 From: Adam Bradley Date: Thu, 21 Jan 2016 16:38:57 -0600 Subject: [PATCH] fix(NavController): default setRoot/setPages to not animate transitions setRoot() will be commonly used by side menus, which should not animate between pages. --- ionic/components/menu/test/basic/index.ts | 15 ++++++--------- ionic/components/nav/nav-controller.ts | 5 +++++ 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/ionic/components/menu/test/basic/index.ts b/ionic/components/menu/test/basic/index.ts index 2cad458b9e..a23df1a89c 100644 --- a/ionic/components/menu/test/basic/index.ts +++ b/ionic/components/menu/test/basic/index.ts @@ -5,13 +5,12 @@ import {App, IonicApp, Page, NavController, Alert} from 'ionic/ionic'; templateUrl: 'page1.html' }) class Page1 { - constructor(nav: NavController) { - this.nav = nav; - } + constructor(private nav: NavController) {} + presentAlert() { let alert = Alert.create({ title: "New Friend!", - body: "Your friend, Obi wan Kenobi, just accepted your friend request!", + message: "Your friend, Obi wan Kenobi, just accepted your friend request!", cssClass: 'my-alert', buttons: ['Ok'] }); @@ -26,9 +25,8 @@ class Page3 {} @Page({templateUrl: 'page2.html'}) class Page2 { - constructor(nav: NavController) { - this.nav = nav; - } + constructor(private nav: NavController) {} + page3() { this.nav.push(Page3); } @@ -40,8 +38,7 @@ class Page2 { }) class E2EApp { - constructor(app: IonicApp) { - this.app = app; + constructor(private app: IonicApp) { this.rootView = Page1; this.changeDetectionCount = 0; diff --git a/ionic/components/nav/nav-controller.ts b/ionic/components/nav/nav-controller.ts index efd0f5e980..4245f44bb2 100644 --- a/ionic/components/nav/nav-controller.ts +++ b/ionic/components/nav/nav-controller.ts @@ -254,6 +254,11 @@ export class NavController extends Ion { let views = pages.map(p => new ViewController(p.page, p.params)); let enteringView = this._insert(0, views); + // if animation wasn't set to true then default it to NOT animate + if (opts.animate !== true) { + opts.animate = false; + } + // set the nav direction to "back" if it wasn't set opts.direction = opts.direction || 'back';