File tree Expand file tree Collapse file tree 1 file changed +17
-13
lines changed Expand file tree Collapse file tree 1 file changed +17
-13
lines changed Original file line number Diff line number Diff line change 11document . addEventListener ( "DOMContentLoaded" , ( ) => {
22 anchors . options = { visible : "always" } ;
33 anchors . add ( ) ;
4+
5+ window . addEventListener ( "hashchange" , openDetailsForHash ) ;
6+ openDetailsForHash ( ) ;
47} ) ;
58
69$ ( ( ) => {
@@ -10,19 +13,6 @@ $(() => {
1013 } ) ;
1114 hljs . highlightAll ( ) ;
1215
13- // Open details that is at the same level as the target of the hash
14- window . addEventListener ( "hashchange" , ( ) => {
15- const target = document . querySelector ( window . location . hash ) ;
16- if ( ! target ) return ;
17-
18- const siblingDetails = target
19- . closest ( "div.method" )
20- ?. querySelector ( "details" ) ;
21- if ( siblingDetails ) {
22- siblingDetails . open = true ;
23- }
24- } ) ;
25-
2616 $ ( "#navigation" ) . load ( `${ config . rootPath } navigation.html` , ( ) => {
2717 $ ( ".sidebar-sticky .icon" ) . on ( "click" , function ( e ) {
2818 e . preventDefault ( ) ;
@@ -35,3 +25,17 @@ $(() => {
3525 . show ( ) ;
3626 } ) ;
3727} ) ;
28+
29+ // Open details that is at the same level as the target of the hash
30+ function openDetailsForHash ( ) {
31+ const hash = window . location . hash ;
32+ if ( ! hash ) return ;
33+ const target = document . querySelector ( hash ) ;
34+ if ( ! target ) return ;
35+
36+ const siblingDetails = target . closest ( "div.method" ) ?. querySelector ( "details" ) ;
37+ if ( siblingDetails ) {
38+ siblingDetails . open = true ;
39+ target . scrollIntoView ( { behavior : "smooth" , block : "start" } ) ;
40+ }
41+ }
You can’t perform that action at this time.
0 commit comments