Ver código fonte

Docs: Fix Safari scrolling to anchors (#33719)

Shota Matsuda 1 semana atrás
pai
commit
c20f3ffb1a
1 arquivos alterados com 8 adições e 2 exclusões
  1. 8 2
      utils/docs/template/static/scripts/page.js

+ 8 - 2
utils/docs/template/static/scripts/page.js

@@ -30,9 +30,15 @@ if ( typeof hljs !== 'undefined' ) {
 
 	if ( hash ) {
 
-		const element = document.getElementById( hash );
+		window.history.scrollRestoration = 'manual';
 
-		if ( element ) element.scrollIntoView();
+		window.addEventListener( 'pageshow', function () {
+
+			const element = document.getElementById( hash );
+
+			if ( element ) element.scrollIntoView();
+
+		}, { once: true } );
 
 	}
 

粤ICP备19079148号