fix navbar hover thingy (#9616)

Co-authored-by: Freeplay <Freeplay@duck.com>
Reviewed-on: https://codeberg.org/calckey/calckey/pulls/9616
Co-authored-by: Free <freeplay@duck.com>
Co-committed-by: Free <freeplay@duck.com>
This commit is contained in:
Free 2023-02-12 18:42:21 +00:00 committed by Kainoa Kanter
parent 5925703cc9
commit 0ddcafb967

View File

@ -152,14 +152,16 @@ onMounted(() => {
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
tabEl.addEventListener("transitionend", () => { function transition() {
const parentRect = tabsEl.getBoundingClientRect(); const parentRect = tabsEl.getBoundingClientRect();
const rect = tabEl.getBoundingClientRect(); const rect = tabEl.getBoundingClientRect();
const left = (rect.left - parentRect.left + tabsEl?.scrollLeft); const left = (rect.left - parentRect.left + tabsEl?.scrollLeft);
tabHighlightEl.style.width = rect.width + 'px'; tabHighlightEl.style.width = rect.width + 'px';
tabHighlightEl.style.left = left + 'px'; tabHighlightEl.style.left = left + 'px';
tabsEl?.scrollTo({left: left - 80, behavior: "smooth"}); tabsEl?.scrollTo({left: left - 80, behavior: "smooth"});
}) tabEl.removeEventListener("transitionend", transition);
}
tabEl.addEventListener("transitionend", transition);
} }
}); });
}, { }, {