mirror of
https://github.com/Wonderfall/hugo-WonderMod.git
synced 2024-11-25 12:01:37 +01:00
Check if menu
exists before using scroll position logic
This commit is contained in:
parent
b8c7df1ef9
commit
76ea33c89c
@ -25,10 +25,12 @@
|
|||||||
|
|
||||||
<script>
|
<script>
|
||||||
let menu = document.getElementById('menu')
|
let menu = document.getElementById('menu')
|
||||||
|
if (menu) {
|
||||||
menu.scrollLeft = localStorage.getItem("menu-scroll-position");
|
menu.scrollLeft = localStorage.getItem("menu-scroll-position");
|
||||||
menu.onscroll = function () {
|
menu.onscroll = function () {
|
||||||
localStorage.setItem("menu-scroll-position", menu.scrollLeft);
|
localStorage.setItem("menu-scroll-position", menu.scrollLeft);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
document.querySelectorAll('a[href^="#"]').forEach(anchor => {
|
document.querySelectorAll('a[href^="#"]').forEach(anchor => {
|
||||||
anchor.addEventListener("click", function (e) {
|
anchor.addEventListener("click", function (e) {
|
||||||
|
Loading…
Reference in New Issue
Block a user