Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions src/generators/legacy-html/assets/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ const initFeatures = () => {
setupAltDocsLink();
setupFlavorToggles();
setupCopyButton();
setupSidebarScroll();
};

/**
Expand Down Expand Up @@ -199,6 +200,23 @@ const setupCopyButton = () => {
});
};

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' });
}

// Initialize either on DOMContentLoaded or immediately if already loaded
document.addEventListener('DOMContentLoaded', initFeatures);
if (document.readyState !== 'loading') initFeatures();
Loading