diff --git a/assets/js/app.js b/assets/js/app.js index e69de29..069b8c2 100644 --- a/assets/js/app.js +++ b/assets/js/app.js @@ -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); + }); +} diff --git a/layouts/docs/single.html b/layouts/docs/single.html index 1746d0a..d1aec30 100644 --- a/layouts/docs/single.html +++ b/layouts/docs/single.html @@ -1,7 +1,7 @@ {{ define "main" }}
-