Skip to content

Commit a75b84b

Browse files
committed
use redocusaurus on raw specs so we dont run decorators twice
1 parent 1679612 commit a75b84b

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

apify-docs-theme/static/js/custom.js

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,20 @@ function scrollSidebarItemIntoView() {
6161
}
6262
}
6363

64+
// handles automatic scrolling of the API reference sidebar (openapi-docs)
65+
function scrollOpenApiSidebarItemIntoView() {
66+
const $li = document.querySelector(`li > a.menu__link--active[href]`);
67+
68+
if (!$li) {
69+
return;
70+
}
71+
72+
$li.scrollIntoView({
73+
block: 'nearest',
74+
inline: 'center',
75+
});
76+
}
77+
6478
let ticking = false;
6579

6680
document.addEventListener('scroll', () => {
@@ -75,7 +89,10 @@ document.addEventListener('scroll', () => {
7589
}
7690
});
7791

78-
document.addEventListener('DOMContentLoaded', () => {
92+
window.addEventListener('load', () => {
7993
// we need to wait a bit more, since the event fires too soon, and a lot of hydration is done after it
80-
setTimeout(() => scrollSidebarItemIntoView(), 3000);
94+
setTimeout(() => scrollSidebarItemIntoView(), 1000);
95+
96+
// docusaurus-openapi-docs plugin: scroll sidebar into viewport, no need for a large timeout here
97+
setTimeout(() => scrollOpenApiSidebarItemIntoView(), 100);
8198
});

0 commit comments

Comments
 (0)