feat: add scroll-lock as separate file
This commit is contained in:
parent
20eb2a22fd
commit
40dc1b7489
|
@ -1,14 +0,0 @@
|
|||
// 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);
|
||||
});
|
||||
}
|
|
@ -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);
|
||||
});
|
||||
}
|
|
@ -57,6 +57,9 @@
|
|||
{{ $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" -}}
|
||||
|
|
Loading…
Reference in New Issue