@@ -10,18 +10,6 @@ const tocCloseIcon = document.querySelector('.js-mobile-toc-toggle .icon-small-x
1010const tocBookIcon = document . querySelector ( '.js-mobile-toc-toggle .icon-small-bookmark' ) ;
1111const tocEditBtn = document . querySelector ( '.js-toc-edit-btn' ) ;
1212
13- // Fixes Chrome issue where pages with hash params are not scrolling to anchor
14- const chromeHashScroll = ( ) => {
15- const isChrome = / C h r o m e / . test ( navigator . userAgent ) ;
16- if ( window . location . hash && isChrome ) {
17- setTimeout ( function ( ) {
18- const hash = window . location . hash ;
19- window . location . hash = '' ;
20- window . location . hash = hash ;
21- } , 300 ) ;
22- }
23- } ;
24-
2513function isTOCDisabled ( ) {
2614 const toc = document . querySelector ( '#TableOfContents' ) ;
2715 if ( ! toc ) {
@@ -231,9 +219,6 @@ function handleAPIPage() {
231219 }
232220}
233221
234- DOMReady ( chromeHashScroll ) ;
235- DOMReady ( handleAPIPage ) ;
236-
237222if ( tocMobileToggle ) {
238223 tocMobileToggle . addEventListener ( 'click' , toggleMobileTOC ) ;
239224}
@@ -250,3 +235,17 @@ window.addEventListener('resize', () => {
250235window . addEventListener ( 'scroll' , ( ) => {
251236 onScroll ( ) ;
252237} ) ;
238+
239+ DOMReady ( handleAPIPage ) ;
240+
241+ // Fixes Chrome issue where pages with hash params are not scrolling to anchor
242+ window . addEventListener ( 'load' , ( ) => {
243+ const isChrome = / C h r o m e / . test ( navigator . userAgent ) ;
244+ if ( window . location . hash && isChrome ) {
245+ setTimeout ( function ( ) {
246+ const hash = window . location . hash ;
247+ window . location . hash = '' ;
248+ window . location . hash = hash ;
249+ } , 300 ) ;
250+ }
251+ } ) ;
0 commit comments