mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2026-03-13 10:22:08 +08:00
fix(NavController): default setRoot/setPages to not animate transitions
setRoot() will be commonly used by side menus, which should not animate between pages.
This commit is contained in:
@@ -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;
|
||||
|
||||
|
||||
@@ -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';
|
||||
|
||||
|
||||
Reference in New Issue
Block a user