Check if menu exists before using scroll position logic

This commit is contained in:
Aditya Telange 2021-10-30 20:01:35 +05:30
parent b8c7df1ef9
commit 76ea33c89c
No known key found for this signature in database
GPG Key ID: 82E844EF3DA99E77

View File

@ -25,9 +25,11 @@
<script>
let menu = document.getElementById('menu')
menu.scrollLeft = localStorage.getItem("menu-scroll-position");
menu.onscroll = function () {
localStorage.setItem("menu-scroll-position", menu.scrollLeft);
if (menu) {
menu.scrollLeft = localStorage.getItem("menu-scroll-position");
menu.onscroll = function () {
localStorage.setItem("menu-scroll-position", menu.scrollLeft);
}
}
document.querySelectorAll('a[href^="#"]').forEach(anchor => {