mirror of
https://github.com/adityatelange/hugo-PaperMod.git
synced 2026-11-22 12:39:04 +00:00
perf(footer): save menu scroll position once scrolling settles
This commit is contained in:
1 file changed
+8
-3
@@ -50,9 +50,14 @@
|
||||
menu.scrollLeft = parseInt(scrollPosition, 10);
|
||||
}
|
||||
|
||||
menu.onscroll = function () {
|
||||
localStorage.setItem("menu-scroll-position", menu.scrollLeft);
|
||||
}
|
||||
// Save once scrolling settles, not on every event
|
||||
let menuScrollTimeout;
|
||||
menu.addEventListener("scroll", function () {
|
||||
clearTimeout(menuScrollTimeout);
|
||||
menuScrollTimeout = setTimeout(function () {
|
||||
localStorage.setItem("menu-scroll-position", menu.scrollLeft);
|
||||
}, 150);
|
||||
}, { passive: true });
|
||||
}
|
||||
|
||||
document.querySelectorAll('a[href^="#"]').forEach(anchor => {
|
||||
|
||||
Reference in new issue
Block a user