Skip to content

Commit

Permalink
include script for sidenav height
Browse files Browse the repository at this point in the history
  • Loading branch information
seungpark committed Oct 23, 2024
1 parent 64ff051 commit 669ff34
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions src/utils/head-scripts/offline-ui/sidenav.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/**
* For offline HTML builds, sidenav should adjust to scroll position
* so that it is sticky, but takes up full height when scrolled down
* and leaves room for Header Navigation at initial scrollY 0
*/

function updateSidenavHeight() {
const updateScrollY = () => {
// pulled from SIDE_NAV_CONTAINER_ID
// 'docs-side-nav-container'
const sidenavElm = document.querySelector('#docs-side-nav-container');
sidenavElm.style = `--scroll-y: ${window.scrollY}px`;
window.addEventListener('scroll', (e) => {
sidenavElm.style = `--scroll-y: ${e.currentTarget.scrollY}px`;
});
};

// TODO: account for multiple browsers here. Which are we supporting? verify with PD
document.addEventListener('DOMContentLoaded', updateScrollY, false);
}

export default updateSidenavHeight;

0 comments on commit 669ff34

Please sign in to comment.