Perf: optimize sub menu position calculation in desktop header with css replace of javascript

This commit is contained in:
Cell
2022-11-04 12:35:23 +08:00
parent de823d47da
commit f3ce0fd165
5 changed files with 4 additions and 6 deletions
-4
View File
@@ -115,11 +115,7 @@ class FixIt {
}
initMenuDesktop() {
// This is a dirty hack for fixing sub menu position error in desktop header
this.util.forEach(document.querySelectorAll('.has-children, #header-desktop .language'), ($item) => {
$item.addEventListener('mouseover', function () {
this.querySelector('.sub-menu').style.left = `${this.getBoundingClientRect().left}px`;
});
$item.querySelector('.sub-menu').style.minWidth = `${$item.offsetWidth - 8}px`;
});
}