Skip to content

Commit

Permalink
tab.Strip: moveActiveIndicator() => honor the scroll state inside the…
Browse files Browse the repository at this point in the history
… page #5127
  • Loading branch information
tobiu committed Dec 4, 2023
1 parent e594989 commit f5e7f30
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
1 change: 1 addition & 0 deletions resources/scss/src/tab/Strip.scss
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
27 changes: 13 additions & 14 deletions src/tab/Strip.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
});
}
}
Expand All @@ -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) {
Expand All @@ -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`
};
Expand All @@ -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;
Expand All @@ -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)
}
}
}
Expand Down

0 comments on commit f5e7f30

Please sign in to comment.