mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2026-03-13 10:22:08 +08:00
feat(tabs): more touchActive features
This commit is contained in:
@@ -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();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user