diff --git a/src/mami.js/controls/tabs.js b/src/mami.js/controls/tabs.js index 4a6d9f5..0546a15 100644 --- a/src/mami.js/controls/tabs.js +++ b/src/mami.js/controls/tabs.js @@ -84,8 +84,15 @@ const MamiTabsControl = function(options) { await onSwitch(cbCtx); - if(prevTab !== undefined) + if(typeof result.info.onTabForeground === 'function') + await result.info.onTabForeground(); + + if(prevTab !== undefined) { + if(typeof prevTab.onTabBackground === 'function') + await prevTab.onTabBackground(); + await doTransition(transition, cbCtx); + } }; const getExistingTabId = tabInfo => { @@ -133,6 +140,9 @@ const MamiTabsControl = function(options) { onClick: () => switchTab(tabInfo), }); + if(typeof tabInfo.onTabAdd === 'function') + await tabInfo.onTabAdd(); + if(currentTab === undefined) await switchTab(tabInfo); @@ -153,6 +163,9 @@ const MamiTabsControl = function(options) { elem: element, }); + if(typeof tabInfo.onTabRemove === 'function') + await tabInfo.onTabRemove(); + if(currentTab === result.info) await switchTab(tabs.size > 0 ? tabs.keys().next().value : undefined); },