From 562ebd75b05e868645e90aaaa2d059edd15c5d93 Mon Sep 17 00:00:00 2001 From: btea <2356281422@qq.com> Date: Wed, 9 Jul 2025 22:53:43 +0800 Subject: [PATCH 1/2] doc: update --- doc/api_assets/api.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/doc/api_assets/api.js b/doc/api_assets/api.js index e86f110e0346bf..f60ba6e3a6fc1e 100644 --- a/doc/api_assets/api.js +++ b/doc/api_assets/api.js @@ -187,6 +187,16 @@ }); } + function scrollIntoViewWithActiveLink() { + const activeLInk = document.querySelector('.interior ul .active'); + if (activeLInk) { + activeLInk.scrollIntoView({ + behavior: 'smooth', + block: 'center' + }); + } + } + function bootstrap() { // Check if we have JavaScript support. document.documentElement.classList.add('has-js'); @@ -206,6 +216,8 @@ setupFlavorToggles(); setupCopyButton(); + + scrollIntoViewWithActiveLink(); } if (document.readyState === 'loading') { From 6643d19c82774b95be371541148fcac61891ff66 Mon Sep 17 00:00:00 2001 From: btea <2356281422@qq.com> Date: Thu, 10 Jul 2025 08:07:47 +0800 Subject: [PATCH 2/2] doc: update --- doc/api_assets/api.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/doc/api_assets/api.js b/doc/api_assets/api.js index f60ba6e3a6fc1e..30e80cece236af 100644 --- a/doc/api_assets/api.js +++ b/doc/api_assets/api.js @@ -187,12 +187,17 @@ }); } + /** + * Scrolls the active link into view, centering it in the viewport. + * This is useful for documentation pages where the active link should be visible + * when the page loads or when navigating to a section. + */ function scrollIntoViewWithActiveLink() { const activeLInk = document.querySelector('.interior ul .active'); if (activeLInk) { activeLInk.scrollIntoView({ behavior: 'smooth', - block: 'center' + block: 'center', }); } }