mirror of
https://github.com/nodejs/node.git
synced 2025-12-28 07:50:41 +00:00
doc: keep sidebar module visible when navigating docs
PR-URL: https://github.com/nodejs/node/pull/60410 Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
This commit is contained in:
parent
1758b74829
commit
aa948fdbd0
@ -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') {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user