diff --git a/ionic/components/nav/nav-base.js b/ionic/components/nav/nav-base.js index 12e71f38b3..3215cd8872 100644 --- a/ionic/components/nav/nav-base.js +++ b/ionic/components/nav/nav-base.js @@ -197,7 +197,11 @@ export class NavBase { return promise; } - switchActive(enteringItem, opts = {}) { + select(enteringItem, opts = {}) { + if (!enteringItem || this.isTransitioning()) { + return; + } + opts.animation = 'none'; let leavingItem = this.getActive() || new NavItem(); @@ -206,8 +210,6 @@ export class NavBase { leavingItem.willCache(); this.transition(enteringItem, leavingItem, opts, () => { - // transition completed, destroy the leaving item - console.log('switchActive comlete') }); } @@ -492,7 +494,7 @@ export class NavBase { } isActive(item) { - return (item && item.stage === ACTIVE_STATE); + return (item && item.state === ACTIVE_STATE); } clear() { diff --git a/ionic/components/nav/nav.js b/ionic/components/nav/nav.js index 44c26d4522..57ea0fb829 100644 --- a/ionic/components/nav/nav.js +++ b/ionic/components/nav/nav.js @@ -9,9 +9,6 @@ import {ViewContainerRef} from 'angular2/src/core/compiler/view_container_ref'; import {Compiler} from 'angular2/angular2'; import {NavBase} from './nav-base'; -import {NavController} from './nav-controller'; -import {NavItem, NavParams} from './nav-item'; -import {Tabs} from '../tabs/tabs'; import {SwipeHandle} from './swipe-handle'; import {IonicComponent} from '../../config/component'; diff --git a/ionic/components/nav/test/basic/pages/second-page.js b/ionic/components/nav/test/basic/pages/second-page.js index 0db33d5cf6..12ef9f9fc5 100644 --- a/ionic/components/nav/test/basic/pages/second-page.js +++ b/ionic/components/nav/test/basic/pages/second-page.js @@ -9,20 +9,15 @@ import {ThirdPage} from './third-page'; @View({ template: ` Second Page Header - -

-

- -
`, directives: [NavbarTemplate, Navbar, Content] diff --git a/ionic/components/nav/test/basic/pages/third-page.js b/ionic/components/nav/test/basic/pages/third-page.js index 44af44c837..8bbdf6a132 100644 --- a/ionic/components/nav/test/basic/pages/third-page.js +++ b/ionic/components/nav/test/basic/pages/third-page.js @@ -8,16 +8,12 @@ import {NavController, NavbarTemplate, Navbar, Content} from 'ionic/ionic'; @View({ template: ` Third Page Header - -

- -
`, directives: [NavbarTemplate, Navbar, Content] diff --git a/ionic/components/tabs/tab-button.js b/ionic/components/tabs/tab-button.js index 35604c9ede..9f81b958a4 100644 --- a/ionic/components/tabs/tab-button.js +++ b/ionic/components/tabs/tab-button.js @@ -24,14 +24,14 @@ export class TabButton { } onInit() { - this.btnId = 'tab-button-' + this.tab.id; - this.panelId = 'tab-panel-' + this.tab.id; + let id = this.tab.item.id + this.btnId = 'tab-button-' + id; + this.panelId = 'tab-panel-' + id; } onClick(ev) { ev.stopPropagation(); ev.preventDefault(); - - this.tabs.selectTab(this.tab); + this.tabs.select(this.tab); } } diff --git a/ionic/components/tabs/tab.js b/ionic/components/tabs/tab.js index ef697d7897..fdbcec13d1 100644 --- a/ionic/components/tabs/tab.js +++ b/ionic/components/tabs/tab.js @@ -54,12 +54,12 @@ export class Tab { this.navBase = new NavBase(parentNavBase, compiler, elementRef, loader, injector); this.parentNavBase = parentNavBase; - this.tabItem = new NavItem(parentNavBase); - this.tabItem.instance = this - tabs.addTab(this.tabItem); + this.item = new NavItem(parentNavBase); + this.item.instance = this + tabs.add(this.item); - this.panelId = 'tab-panel-' + this.tabItem.id; - this.labeledBy = 'tab-button-' + this.tabItem.id; + this.panelId = 'tab-panel-' + this.item.id; + this.labeledBy = 'tab-button-' + this.item.id; this.elementRef = elementRef; @@ -68,15 +68,14 @@ export class Tab { this.sections = parentNavBase.panes['_n'].sections; this.navBase.panes['_n'] = this; - this.domElement = elementRef.domElement; this.config = Nav.config.invoke(this); - console.log('Tab constructor', this.id, ' parentNavBase:', parentNavBase); + console.log('Tab constructor', this.item.id, ' parentNavBase:', parentNavBase); } get isSelected() { - return this.parentNavBase.isActive(this); + return this.parentNavBase.isActive(this.item); } } diff --git a/ionic/components/tabs/tabs.js b/ionic/components/tabs/tabs.js index 52fe2b38cc..2ac1e9fc1e 100644 --- a/ionic/components/tabs/tabs.js +++ b/ionic/components/tabs/tabs.js @@ -55,11 +55,11 @@ export class Tabs { this.config = Tabs.config.invoke(this); } - addTab(tabItem) { + add(tabItem) { this.navBase.add(tabItem); if (this.navBase.length() === 1) { - this.selectTab(tabItem.instance); + this.select(tabItem.instance); } } @@ -67,10 +67,8 @@ export class Tabs { return this.navBase.instances(); } - selectTab(tabInstance) { - let enteringItem = this.navBase.findByInstance(tabInstance); - - this.navBase.switchActive(enteringItem); + select(tabInstance) { + this.navBase.select( this.navBase.findByInstance(tabInstance) ); } }