Skip to content

Commit

Permalink
use redocusaurus on raw specs so we dont run decorators twice
Browse files Browse the repository at this point in the history
  • Loading branch information
B4nan committed Nov 28, 2024
1 parent 1679612 commit a75b84b
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions apify-docs-theme/static/js/custom.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,20 @@ function scrollSidebarItemIntoView() {
}
}

// handles automatic scrolling of the API reference sidebar (openapi-docs)
function scrollOpenApiSidebarItemIntoView() {
const $li = document.querySelector(`li > a.menu__link--active[href]`);

if (!$li) {
return;
}

$li.scrollIntoView({
block: 'nearest',
inline: 'center',
});
}

let ticking = false;

document.addEventListener('scroll', () => {
Expand All @@ -75,7 +89,10 @@ document.addEventListener('scroll', () => {
}
});

document.addEventListener('DOMContentLoaded', () => {
window.addEventListener('load', () => {
// we need to wait a bit more, since the event fires too soon, and a lot of hydration is done after it
setTimeout(() => scrollSidebarItemIntoView(), 3000);
setTimeout(() => scrollSidebarItemIntoView(), 1000);

// docusaurus-openapi-docs plugin: scroll sidebar into viewport, no need for a large timeout here
setTimeout(() => scrollOpenApiSidebarItemIntoView(), 100);
});

0 comments on commit a75b84b

Please sign in to comment.