Skip to content

Commit 9e8ddb7

Browse files
committed
address feedback
1 parent 8eeddfb commit 9e8ddb7

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

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

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,12 @@
3434
// }, 500);
3535

3636
let lastKnownScrollHash = '';
37-
let ticking = false;
3837

39-
function doSomething() {
38+
// handles automatic scrolling of the API reference sidebar (redoc)
39+
function scrollSidebarItemIntoView() {
4040
const hash = window.location.hash.substring(1);
4141

4242
if (hash !== lastKnownScrollHash) {
43-
console.log(hash, `li[data-item-id="${hash}"]`);
4443
const $li = document.querySelector(`li[data-item-id="${hash}"]`);
4544

4645
if (!$li) {
@@ -62,10 +61,13 @@ function doSomething() {
6261
}
6362
}
6463

64+
let ticking = false;
65+
6566
document.addEventListener('scroll', () => {
6667
if (!ticking) {
68+
// throttling based on current frame rate
6769
window.requestAnimationFrame(() => {
68-
doSomething();
70+
scrollSidebarItemIntoView();
6971
ticking = false;
7072
});
7173

0 commit comments

Comments
 (0)