Added event calls to tabs control.

This commit is contained in:
flash 2024-01-23 16:37:04 +00:00
parent 1e439b87c0
commit 2f4eb11bfa

View file

@ -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);
},