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
+1
View File
@@ -13,6 +13,7 @@ All notable changes to this project will be documented in this file.
- :sparkles: Feat: add params to close wordcount and readingTime in post ([#209](https://github.com/hugo-fixit/FixIt/issues/209))
- :truck: Feat: migrate parameter `params.autoBookmark` to `params.page.autoBookmark` ([#55](https://github.com/hugo-fixit/FixIt/issues/55))
- :zap: Perf: optimize close comment feature when the post has expired ([#204](https://github.com/hugo-fixit/FixIt/issues/204))
- :zap: Perf: optimize sub menu position calculation in desktop header with css replace of javascript
- :bug: Fix: remove the leading and trailing whitespace of the code string ([#205](https://github.com/hugo-fixit/FixIt/issues/205))
- :bento: Fix: update webfonts for fontawesome 6.2.0 (@NicoDreamzZ[#228](https://github.com/hugo-fixit/FixIt/pull/228))
- :bug: Fix: image shortcode/plugin lose the support for svg type files ([#210](https://github.com/hugo-fixit/FixIt/issues/210))
+1
View File
@@ -219,6 +219,7 @@ header {
>.menu-item:hover {
& .sub-menu {
display: block;
transform: translateX(-0.5rem);
}
}
+1 -1
View File
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
-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`;
});
}