Top nav fixes (#9634)
Co-authored-by: Free <freeplay@duck.com> Co-committed-by: Free <freeplay@duck.com>
This commit is contained in:
parent
0cc81624b5
commit
9093319906
@ -144,21 +144,20 @@ onMounted(() => {
|
|||||||
calcBg();
|
calcBg();
|
||||||
globalEvents.on('themeChanged', calcBg);
|
globalEvents.on('themeChanged', calcBg);
|
||||||
|
|
||||||
|
|
||||||
watch(() => [props.tab, props.tabs], () => {
|
watch(() => [props.tab, props.tabs], () => {
|
||||||
nextTick(() => {
|
nextTick(() => {
|
||||||
const tabEl = tabRefs[props.tab];
|
const tabEl = tabRefs[props.tab];
|
||||||
if (tabEl && tabHighlightEl) {
|
if (tabEl && tabHighlightEl) {
|
||||||
// offsetWidth や offsetLeft は少数を丸めてしまうため getBoundingClientRect を使う必要がある
|
// offsetWidth や offsetLeft は少数を丸めてしまうため getBoundingClientRect を使う必要がある
|
||||||
// https://developer.mozilla.org/ja/docs/Web/API/HTMLElement/offsetWidth#%E5%80%A4
|
// https://developer.mozilla.org/ja/docs/Web/API/HTMLElement/offsetWidth#%E5%80%A4
|
||||||
|
const tabSizeX = tabEl.scrollWidth + 20; // + the tab's padding
|
||||||
|
tabEl.style = `--width: ${tabSizeX}px`;
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
const parentRect = tabsEl.getBoundingClientRect();
|
const parentRect = tabsEl.getBoundingClientRect();
|
||||||
const rect = tabEl.getBoundingClientRect();
|
const rect = tabEl.getBoundingClientRect();
|
||||||
const tabSizeX = tabEl.scrollWidth;
|
|
||||||
const left = (rect.left - parentRect.left + tabsEl?.scrollLeft);
|
const left = (rect.left - parentRect.left + tabsEl?.scrollLeft);
|
||||||
tabEl.style = "--width: " + tabSizeX + "px";
|
|
||||||
tabHighlightEl.style.width = tabSizeX + 'px';
|
tabHighlightEl.style.width = tabSizeX + 'px';
|
||||||
tabHighlightEl.style.transform = 'translateX(' + left + 'px)';
|
tabHighlightEl.style.transform = `translateX(${left}px)`;
|
||||||
window.requestAnimationFrame(() => {
|
window.requestAnimationFrame(() => {
|
||||||
tabsEl?.scrollTo({left: left - 60, behavior: "smooth"});
|
tabsEl?.scrollTo({left: left - 60, behavior: "smooth"});
|
||||||
})
|
})
|
||||||
@ -358,11 +357,12 @@ onUnmounted(() => {
|
|||||||
display: inline-flex;
|
display: inline-flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
position: relative;
|
position: relative;
|
||||||
padding: 0 10px;
|
border-inline: 10px solid transparent;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
font-weight: normal;
|
font-weight: normal;
|
||||||
opacity: 0.7;
|
opacity: 0.7;
|
||||||
width: 38px;
|
width: 38px;
|
||||||
|
--width: 38px;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
transition: color .2s, opacity .2s, width .2s;
|
transition: color .2s, opacity .2s, width .2s;
|
||||||
|
|
||||||
@ -384,7 +384,7 @@ onUnmounted(() => {
|
|||||||
margin-left: 8px;
|
margin-left: 8px;
|
||||||
}
|
}
|
||||||
> .title {
|
> .title {
|
||||||
transition: font-size .2s, opacity .2s;
|
transition: opacity .2s;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user