File tree Expand file tree Collapse file tree 2 files changed +24
-0
lines changed Expand file tree Collapse file tree 2 files changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -109,6 +109,7 @@ const siteConfig = {
109
109
'https://buttons.github.io/buttons.js' ,
110
110
'https://cdnjs.cloudflare.com/ajax/libs/clipboard.js/2.0.0/clipboard.min.js' ,
111
111
'/js/code-block-buttons.js' ,
112
+ '/js/sidenav.js' ,
112
113
] ,
113
114
114
115
stylesheets : [
Original file line number Diff line number Diff line change
1
+ // See https://github.com/reactioncommerce/reaction-docs/pull/686/files
2
+ // https://github.com/facebook/Docusaurus/issues/823
3
+
4
+ document . addEventListener ( 'DOMContentLoaded' , ( ) => {
5
+ // Find the active nav item in the sidebar
6
+ const item = document . getElementsByClassName ( 'navListItemActive' ) [ 0 ]
7
+ if ( ! item ) {
8
+ return
9
+ }
10
+ const bounding = item . getBoundingClientRect ( )
11
+ if (
12
+ bounding . top >= 0 &&
13
+ bounding . bottom <=
14
+ ( window . innerHeight || document . documentElement . clientHeight )
15
+ ) {
16
+ // Already visible. Do nothing.
17
+ } else {
18
+ // Not visible. Scroll sidebar.
19
+ item . scrollIntoView ( { block : 'center' , inline : 'nearest' } )
20
+ document . body . scrollTop = 0
21
+ document . documentElement . scrollTop = 0
22
+ }
23
+ } )
You can’t perform that action at this time.
0 commit comments