Skip to content

Commit

Permalink
Fixed extra height - DP-19782
Browse files Browse the repository at this point in the history
  • Loading branch information
tom-fleming committed Sep 4, 2020
1 parent 99d146b commit 3b4d6ac
Showing 1 changed file with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const utilNavNarrowCheck = function() {
/** DP-19336 begin: add padding to hamburger menu to allow scrolling when alerts are loaded */
const hamburgerMainNav = document.querySelector(".ma__header__hamburger__main-nav");
let emergencyAlerts = document.querySelector(".ma__emergency-alerts__content");
let hamburgerMenuAlertScrolling = function() {
let hamburgerMenuAlertScrolling = function(scrollOffset = 0) {
if (hamburgerMainNav !== null && emergencyAlerts !== null) {
let alertHeight = document.querySelector(".ma__emergency-alerts").clientHeight || 0;
let hamburgerMenuTop = document.querySelector(".ma__header__hamburger__nav-container").offsetTop || 0;
Expand All @@ -38,7 +38,7 @@ let hamburgerMenuAlertScrolling = function() {
}

// Add bottom padding when function is initially called.
paddingTarget.style.paddingBottom = alertHeight + hamburgerMenuTop + "px";
paddingTarget.style.paddingBottom = alertHeight + hamburgerMenuTop - scrollOffset + "px";

// Add bottom padding when alert style changes occur.
const alertObserver = new MutationObserver(function(mutations) {
Expand All @@ -59,7 +59,7 @@ let hamburgerMenuAlertScrolling = function() {
let currentDisplayValue = document.querySelector(".ma__emergency-alerts__content").style.display;
if (currentDisplayValue === oldDisplayValue) {
alertHeight = document.querySelector(".ma__emergency-alerts").clientHeight;
paddingTarget.style.paddingBottom = alertHeight + hamburgerMenuTop + "px";
paddingTarget.style.paddingBottom = alertHeight + hamburgerMenuTop - scrollOffset + "px";
}
}
});
Expand Down Expand Up @@ -546,12 +546,14 @@ function openMenu() {
};

customScrollTo(scrollOffset, 250);
hamburgerMenuAlertScrolling(scrollOffset);
} else {
window.scrollTo({
top: scrollOffset,
left: 0,
behavior: "smooth"
});
hamburgerMenuAlertScrolling(scrollOffset);
}
}
}
Expand Down Expand Up @@ -682,6 +684,7 @@ if (null !== menuOverlay) {

let debouncer;
window.addEventListener("resize", function () {
closeMenu();
clearTimeout(debouncer);
debouncer = setTimeout( () => {
hamburgerMenuAlertScrolling();
Expand Down

0 comments on commit 3b4d6ac

Please sign in to comment.