Merge pull request #648 from h-enk/scroll-lock
Adds scroll position lock for default docs sidebar
This commit is contained in:
commit
5466150f72
|
@ -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" }}
|
{{ define "main" }}
|
||||||
<div class="row flex-xl-nowrap">
|
<div class="row flex-xl-nowrap">
|
||||||
<div class="col-lg-5 col-xl-4 docs-sidebar d-none d-lg-block">
|
<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" . }}
|
{{ partial "sidebar/docs-menu.html" . }}
|
||||||
</nav>
|
</nav>
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Reference in New Issue