diff --git a/assets/js/index.js b/assets/js/index.js index d6b9c7c080..33ebfe6287 100644 --- a/assets/js/index.js +++ b/assets/js/index.js @@ -103,6 +103,20 @@ Array.from(searchForms).forEach(container => { } }); +const menuPositioner = () => { + const nav = document.querySelectorAll("#sidebar-default")[1] + const itemActive = document.querySelectorAll(".sidebar-item-active") + const itemActiveMobile = document.querySelectorAll(".offcanvas-body .sidebar-item-active") + const navMobile = document.querySelector(".offcanvas-body") + + if (itemActive.length) { + nav.scrollTop = itemActive[itemActive.length - 1].offsetTop - 300 + navMobile.scrollTop = itemActiveMobile[itemActiveMobile.length - 1].offsetTop - 200 + } +} + +menuPositioner() + window.addEventListener('load', function() { index = new FlexSearch.Document({ tokenize: "forward", diff --git a/layouts/partials/footer/script-footer.html b/layouts/partials/footer/script-footer.html index 56f343e916..379f654241 100644 --- a/layouts/partials/footer/script-footer.html +++ b/layouts/partials/footer/script-footer.html @@ -57,9 +57,6 @@ {{ $slice = $slice | append $katexConfig -}} {{ end -}} -{{ $scrollLock := resources.Get "js/scroll-lock.js" | js.Build -}} -{{ $slice = $slice | append $scrollLock -}} - {{ $js := $slice | resources.Concat "main.js" -}} {{ if eq (hugo.Environment) "development" -}}