From 2f4eb11bfaa9f17b3b34ed629bc9a08571bdf2ee Mon Sep 17 00:00:00 2001 From: flashwave Date: Tue, 23 Jan 2024 16:37:04 +0000 Subject: [PATCH] Added event calls to tabs control. --- src/mami.js/controls/tabs.js | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) 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); },