File tree Expand file tree Collapse file tree 1 file changed +10
-14
lines changed Expand file tree Collapse file tree 1 file changed +10
-14
lines changed Original file line number Diff line number Diff line change @@ -31,7 +31,7 @@ export function Events(Base) {
3131
3232 // Move focus to content
3333 if ( query . id || source === 'navigate' ) {
34- this . focusContent ( ) ;
34+ this . # focusContent( ) ;
3535 }
3636
3737 if ( loadNavbar ) {
@@ -139,19 +139,15 @@ export function Events(Base) {
139139 #enableScrollEvent = true ;
140140 #coverHeight = 0 ;
141141
142- #skipLink( el ) {
143- el = dom . getNode ( el ) ;
144-
145- if ( el === null || el === undefined ) {
146- return ;
147- }
148-
149- dom . on ( el , 'click' , evt => {
150- const target = dom . getNode ( '#main' ) ;
142+ #skipLink( elm ) {
143+ elm = typeof elm === 'string' ? dom . find ( elm ) : elm ;
151144
145+ elm ?. addEventListener ( 'click' , evt => {
152146 evt . preventDefault ( ) ;
153- target && target . focus ( ) ;
154- this . #scrollTo( target ) ;
147+ dom . getNode ( 'main' ) ?. scrollIntoView ( {
148+ behavior : 'smooth' ,
149+ } ) ;
150+ this . #focusContent( { preventScroll : true } ) ;
155151 } ) ;
156152 }
157153
@@ -177,7 +173,7 @@ export function Events(Base) {
177173 . begin ( ) ;
178174 }
179175
180- focusContent ( ) {
176+ # focusContent( options = { } ) {
181177 const { query } = this . route ;
182178 const focusEl = query . id
183179 ? // Heading ID
@@ -188,7 +184,7 @@ export function Events(Base) {
188184 dom . find ( '#main' ) ;
189185
190186 // Move focus to content area
191- focusEl && focusEl . focus ( ) ;
187+ focusEl && focusEl . focus ( options ) ;
192188 }
193189
194190 #highlight( path ) {
You can’t perform that action at this time.
0 commit comments