File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -48,6 +48,27 @@ export default {
4848 } ;
4949 onMounted ( ( ) => {
5050 initZoom ( ) ;
51+ // Re-scroll to hash after fonts/layout settle. Firefox does not re-scroll
52+ // after late layout shifts on huge pages (e.g. common.html), so the
53+ // initial anchor jump lands far off. Run only on initial load.
54+ if ( inBrowser && location . hash ) {
55+ const id = decodeURIComponent ( location . hash . slice ( 1 ) ) ;
56+ const fontsReady = document . fonts ?. ready ?? Promise . resolve ( ) ;
57+ const loadReady =
58+ document . readyState === "complete"
59+ ? Promise . resolve ( )
60+ : new Promise ( ( r ) =>
61+ window . addEventListener ( "load" , r , { once : true } )
62+ ) ;
63+ Promise . all ( [ fontsReady , loadReady ] ) . then ( ( ) => {
64+ requestAnimationFrame ( ( ) =>
65+ requestAnimationFrame ( ( ) => {
66+ const el = document . getElementById ( id ) ;
67+ if ( el ) el . scrollIntoView ( ) ;
68+ } )
69+ ) ;
70+ } ) ;
71+ }
5172 } ) ;
5273 watch (
5374 ( ) => route . path ,
Original file line number Diff line number Diff line change 157157 display : inline; /* block by default set by vitepress */
158158}
159159
160+ /* Fix deep-link anchor offset under fixed navbar.
161+ Also guards against Firefox layout-shift drift on huge pages (e.g. common.html). */
162+ html {
163+ scroll-padding-top : calc (var (--vp-nav-height , 64px ) + 16px );
164+ }
165+ : target {
166+ scroll-margin-top : calc (var (--vp-nav-height , 64px ) + 16px );
167+ }
168+
160169/* Make content area a little wider to improve tables */
161170.content-container {
162171 max-width : 100% !important ;
You can’t perform that action at this time.
0 commit comments