Merge pull request #648 from h-enk/scroll-lock

Adds scroll position lock for default docs sidebar
This commit is contained in:
Henk Verlinde 2022-02-02 11:03:03 +01:00 committed by GitHub
commit 5466150f72
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 1 deletions

View File

@ -0,0 +1,14 @@
// Adds scroll position lock for default docs sidebar
if (document.querySelector('#sidebar-default') !== null) {
let sidebar = document.getElementById('sidebar-default');
let pos = sessionStorage.getItem('sidebar-scroll');
if (pos !== null) {
sidebar.scrollTop = parseInt(pos, 10);
}
window.addEventListener('beforeunload', () => {
sessionStorage.setItem('sidebar-scroll', sidebar.scrollTop);
});
}

View File

@ -1,7 +1,7 @@
{{ define "main" }}
<div class="row flex-xl-nowrap">
<div class="col-lg-5 col-xl-4 docs-sidebar d-none d-lg-block">
<nav class="docs-links" aria-label="Main navigation">
<nav {{ if eq .Site.Params.menu.section.collapsibleSidebar false }}id="sidebar-default" {{ end }}class="docs-links" aria-label="Main navigation">
{{ partial "sidebar/docs-menu.html" . }}
</nav>
</div>