File tree Expand file tree Collapse file tree 2 files changed +26
-0
lines changed
Expand file tree Collapse file tree 2 files changed +26
-0
lines changed Original file line number Diff line number Diff line change 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+ } ) ( ) ;
Original file line number Diff line number Diff line change @@ -44,3 +44,4 @@ plugins:
4444extra_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
You can’t perform that action at this time.
0 commit comments