ux: add scroll position lock for default docs sidebar
This commit is contained in:
parent
971894755e
commit
17eb9a6902
|
@ -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);
|
||||
});
|
||||
}
|
|
@ -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>
|
||||
|
|
Loading…
Reference in New Issue