Skip to content

Commit

Permalink
feat(super-tabs): fire view events
Browse files Browse the repository at this point in the history
willEnter, didEnter, willLeave, didLeave
  • Loading branch information
ihadeed committed May 1, 2017
1 parent 01e7a85 commit 78b7bc7
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/components/super-tabs/super-tabs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -426,13 +426,25 @@ export class SuperTabs implements OnInit, AfterContentInit, AfterViewInit, OnDes
*/
onTabChange(index: number) {
if (index <= this._tabs.length) {
const currentTab: SuperTab = this.getActiveTab();
let activeView: ViewController = currentTab.getActive();

activeView._willLeave(false);
activeView._didLeave();

this.selectedTabIndex = index;

this.linker.navChange('switch');

this.refreshTabStates();

activeView = this.getActiveTab().getActive();

if (activeView) {
activeView._willEnter();
activeView._didEnter();
}

this.tabSelect.emit({
index,
id: this._tabs[index].tabId
Expand Down Expand Up @@ -566,6 +578,10 @@ export class SuperTabs implements OnInit, AfterContentInit, AfterViewInit, OnDes
return this._tabs.find((tab: SuperTab) => tab.tabId === tabId);
}

getActiveTab(): SuperTab {
return this._tabs[this.selectedTabIndex];
}

getElementRef() { return this.el; }

initPane() { return true; }
Expand Down

0 comments on commit 78b7bc7

Please sign in to comment.