feat(tabs): more touchActive features

This commit is contained in:
Max Lynch
2015-11-05 21:11:16 -06:00
parent f8872a47b0
commit aff112a5a1

View File

@@ -217,15 +217,36 @@ export class Tabs extends Ion {
/**
* @private
* "Touch" the active tab, either going back to the root view of the tab
* or scrolling the tab to the top
* "Touch" the active tab, going back to the root view of the tab
* or optionally letting the tab handle the event
*/
touchActive(tab) {
let active = tab.getActive();
if(!active) {
return Promise.resolve();
}
let instance = active.instance;
// If they have a custom tab selected handler, call it
if(instance.tabSelected) {
return instance.tabSelected();
}
// If we're a few pages deep, pop to root
if (tab.length() > 1) {
// Pop to the root view
return tab.popToRoot();
}
// Otherwise, if the page we're on is not our real root, reset it to our
// default root type
if(tab.root != active.componentType) {
return tab.setRoot(tab.root);
}
// And failing all of that, we do something safe and secure
return Promise.resolve();
}