Skip to content

Commit

Permalink
Updated resize event logic
Browse files Browse the repository at this point in the history
  • Loading branch information
nick-mon1 committed Feb 10, 2025
1 parent d3ee1b6 commit 771f563
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions themes/digital.gov/src/js/guide-menu-bar.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ function scrollMenuBar(offset) {
* in alignment with dg-guide__content and HCD guides dg-guide__container
* */
function adjustMenuPadding() {
console.log("calling resize");
let container = null;
if (guideSideNav) {
container = guideContainer;
Expand Down Expand Up @@ -67,8 +68,8 @@ function intersection(e) {
"grid-container",
"grid-container-desktop"
);

adjustMenuPadding();
window.addEventListener("resize", adjustMenuPadding);
menuBarImage.removeAttribute("hidden");
menuBarImage.setAttribute("tabindex", "0");
// Check if viewing on mobile device
Expand All @@ -83,6 +84,7 @@ function intersection(e) {
menuBarImage.setAttribute("tabindex", "-1");
menuBarLinks.style.paddingLeft = 0;
menuBar.classList.remove("sticky");
window.removeEventListener("resize", adjustMenuPadding);
menuBarContainer.classList.add("grid-container", "grid-container-desktop");
scrollMenuBar(menuBarScrollOffsetDefault);
}
Expand All @@ -103,4 +105,3 @@ document.addEventListener("DOMContentLoaded", () => {
});

// Adjust padding when the window resizes
window.addEventListener("resize", adjustMenuPadding);

0 comments on commit 771f563

Please sign in to comment.