File tree Expand file tree Collapse file tree 1 file changed +4
-4
lines changed Expand file tree Collapse file tree 1 file changed +4
-4
lines changed Original file line number Diff line number Diff line change 17
17
var originalPageItem = currentPageItem
18
18
if ( currentPageItem ) {
19
19
activateCurrentPath ( currentPageItem )
20
- scrollItemToMidpoint ( menuPanel , currentPageItem . querySelector ( '.nav-link' ) )
20
+ scrollItemToMidpoint ( menuPanel , currentPageItem )
21
21
} else {
22
22
menuPanel . scrollTop = 0
23
23
}
29
29
} )
30
30
if ( currentPageItem ) {
31
31
if ( collapse ) activateCurrentPath ( currentPageItem , false )
32
- scrollItemToMidpoint ( menuPanel , currentPageItem . querySelector ( '.nav-link' ) )
32
+ scrollItemToMidpoint ( menuPanel , currentPageItem )
33
33
} else if ( collapse ) {
34
34
menuPanel . scrollTop = 0
35
35
}
89
89
} )
90
90
; ( currentPageItem = navItem ) . classList . add ( 'is-current-page' )
91
91
activateCurrentPath ( currentPageItem )
92
- scrollItemToMidpoint ( menuPanel , navLink )
92
+ scrollItemToMidpoint ( menuPanel , currentPageItem )
93
93
}
94
94
95
95
if ( menuPanel . querySelector ( '.nav-link[href^="#"]' ) ) {
153
153
function scrollItemToMidpoint ( panel , item ) {
154
154
if ( panel . scrollHeight === panel . clientHeight ) return // not scrollable
155
155
var panelRect = panel . getBoundingClientRect ( )
156
- var linkRect = item . getBoundingClientRect ( )
156
+ var linkRect = item . querySelector ( '.nav-link' ) . getBoundingClientRect ( )
157
157
panel . scrollTop += Math . round ( linkRect . top - panelRect . top - ( panelRect . height - linkRect . height ) * 0.5 )
158
158
}
159
159
You can’t perform that action at this time.
0 commit comments