diff --git a/doc/api_assets/api.js b/doc/api_assets/api.js index e86f110e0346bf..a3e479ed9569c3 100644 --- a/doc/api_assets/api.js +++ b/doc/api_assets/api.js @@ -187,6 +187,20 @@ }); } + function setupSidebarScroll() { + const sidebarLinks = document.querySelectorAll('#column2 a'); + + let link; + for (link of sidebarLinks) { + if (link.pathname === window.location.pathname) break; + } + + if (!link) return; + + link.scrollIntoView({ block: 'center' }); + } + + function bootstrap() { // Check if we have JavaScript support. document.documentElement.classList.add('has-js'); @@ -206,6 +220,8 @@ setupFlavorToggles(); setupCopyButton(); + + setupSidebarScroll(); } if (document.readyState === 'loading') {