Skip to content

Commit f27b0c0

Browse files
committed
Fix sidebar
1 parent db3ead3 commit f27b0c0

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// Defensive scroll-unlock for Material sidebar
2+
(function () {
3+
try {
4+
document.addEventListener(
5+
"click",
6+
function (ev) {
7+
var el = ev.target;
8+
if (!(el instanceof Element)) return;
9+
var link = el.closest("a.md-nav__link, .md-sidebar a, a");
10+
if (!link) return;
11+
if (link.target && link.target !== "") return;
12+
if (document.body.hasAttribute("data-md-scrolllock")) {
13+
var top = parseInt(document.body.style.top || "0") || 0;
14+
document.body.removeAttribute("data-md-scrolllock");
15+
document.body.style.top = "";
16+
if (top)
17+
try {
18+
window.scrollTo(0, -top);
19+
} catch (e) {}
20+
}
21+
},
22+
true,
23+
);
24+
} catch (e) {}
25+
})();

mkdocs.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,3 +44,4 @@ plugins:
4444
extra_javascript:
4545
- https://polyfill.io/v3/polyfill.min.js?features=es6
4646
- https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js
47+
- assets/javascripts/scroll-unlock.js

0 commit comments

Comments
 (0)