File tree Expand file tree Collapse file tree 1 file changed +6
-4
lines changed
apify-docs-theme/static/js Expand file tree Collapse file tree 1 file changed +6
-4
lines changed Original file line number Diff line number Diff line change 3434// }, 500);
3535
3636let 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+
6566document . addEventListener ( 'scroll' , ( ) => {
6667 if ( ! ticking ) {
68+ // throttling based on current frame rate
6769 window . requestAnimationFrame ( ( ) => {
68- doSomething ( ) ;
70+ scrollSidebarItemIntoView ( ) ;
6971 ticking = false ;
7072 } ) ;
7173
You can’t perform that action at this time.
0 commit comments