From f5e7f30ec91ff490e2ba5c47fa8669e9d0b4fc07 Mon Sep 17 00:00:00 2001 From: tobiu Date: Mon, 4 Dec 2023 14:02:10 +0100 Subject: [PATCH] tab.Strip: moveActiveIndicator() => honor the scroll state inside the page #5127 --- resources/scss/src/tab/Strip.scss | 1 + src/tab/Strip.mjs | 27 +++++++++++++-------------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/resources/scss/src/tab/Strip.scss b/resources/scss/src/tab/Strip.scss index 304d7d56e..056657592 100644 --- a/resources/scss/src/tab/Strip.scss +++ b/resources/scss/src/tab/Strip.scss @@ -2,6 +2,7 @@ background-color: var(--tab-strip-background-color); height : var(--tab-strip-height); overflow : hidden; + position : relative; .neo-active-tab-indicator { background-color : var(--tab-indicator-background-color-active); diff --git a/src/tab/Strip.mjs b/src/tab/Strip.mjs index a0d960872..d23d45c0d 100644 --- a/src/tab/Strip.mjs +++ b/src/tab/Strip.mjs @@ -65,21 +65,19 @@ class Strip extends Component { */ getActiveTabRectThenMove(opts) { let me = this, - ids = [], + ids = [me.id], tabContainer = me.getTabContainer(); if (me.vnode) { if (opts) { - ids.push(tabContainer.getTabAtIndex(opts.value), tabContainer.getTabAtIndex(opts.oldValue)); + ids.push(tabContainer.getTabAtIndex(opts.value).id, tabContainer.getTabAtIndex(opts.oldValue).id) } else { - ids.push(tabContainer.getTabAtIndex(tabContainer.activeIndex)); + ids.push(tabContainer.getTabAtIndex(tabContainer.activeIndex).id) } - ids = ids.map(e => e?.id).filter(Boolean); - if (me.useActiveTabIndicator) { me.getDomRect(ids).then(data => { - me.moveActiveIndicator(data); + me.moveActiveIndicator(data) }); } } @@ -105,8 +103,9 @@ class Strip extends Component { * @param {Number} rects[0].y */ moveActiveIndicator(rects) { - let me = this, - rect = rects[1] || rects[0], + let me = this, + tabStripRect = rects.shift(), + rect = rects[1] || rects[0], activeTabIndicator, tabContainer; if (me.useActiveTabIndicator) { @@ -118,7 +117,7 @@ class Strip extends Component { case 'top': activeTabIndicator.style = { height: null, - left : `${rect.left}px`, + left : `${rect.left - tabStripRect.left}px`, top : null, width : `${rect.width}px` }; @@ -128,7 +127,7 @@ class Strip extends Component { activeTabIndicator.style = { height: `${rect.height}px`, left : null, - top : `${rect.top}px`, + top : `${rect.top - tabStripRect.top}px`, width : null }; break; @@ -140,16 +139,16 @@ class Strip extends Component { me.update(); setTimeout(() => { - me.moveActiveIndicator([rects[0]]); + me.moveActiveIndicator([tabStripRect, rects[0]]); }, 50) } else { activeTabIndicator.style.opacity = 1; me.update(); setTimeout(() => { - activeTabIndicator.style.opacity = 0; - me.update(); - }, 300); + //activeTabIndicator.style.opacity = 0; + me.update() + }, 300) } } }