Skip to content

Commit

Permalink
eslint
Browse files Browse the repository at this point in the history
  • Loading branch information
sharmrj committed Jan 6, 2025
1 parent 6e4b19f commit be22936
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 18 deletions.
7 changes: 4 additions & 3 deletions libs/blocks/global-navigation/global-navigation.js
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,7 @@ class Gnav {
let localNav = document.querySelector('.feds-localnav');
if (!localNav) {
lanaLog({ message: 'GNAV: Localnav does not include \'localnav\' in its name.', tags: 'errorType=info,module=gnav' });
localNav = toFragment`<div class="feds-localnav"/>`;
localNav = toFragment`<div class="feds-localnav"/>`
this.block.after(localNav);
}
localNav.setAttribute('daa-lh', `${title}_localNav`);
Expand Down Expand Up @@ -1125,8 +1125,9 @@ class Gnav {
dropdownTrigger.addEventListener('click', (e) => {
if (!isDesktop.matches && this.newMobileNav && isSectionMenu) {
const popup = dropdownTrigger.nextElementSibling;
const y = Math.abs(parseInt(document.body.style.top));
// document.body.style.top should always be set at this point by calling disableMobileScroll
const y = Math.abs(parseInt(document.body.style.top, 10));
// document.body.style.top should always be set
// at this point by calling disableMobileScroll
if (popup) popup.style = `top: calc(${y || 0}px - var(--feds-height-nav) - 1px)`;
makeTabActive(popup);
}
Expand Down
29 changes: 14 additions & 15 deletions libs/blocks/global-navigation/utilities/utilities.js
Original file line number Diff line number Diff line change
Expand Up @@ -413,6 +413,20 @@ export const closeAllTabs = (tabs, tabpanels) => {
tabs.forEach((t) => t.setAttribute('aria-selected', 'false'));
};

export const disableMobileScroll = () => {
document.body.style.top = `-${window.scrollY}px`;
document.body.classList.add('disable-ios-scroll');
};

export const enableMobileScroll = () => {
if (!document.body.style.top) return;
const y = Math.abs(parseInt(document.body.style.top, 10));
if (isNaN(y)) return;
document.body.classList.remove('disable-ios-scroll');
document.body.style.removeProperty('top');
window.scroll(0, y || 0);
};

export const transformTemplateToMobile = async (popup, item, localnav = false) => {
const notMegaMenu = popup.parentElement.tagName === 'DIV';
const originalContent = popup.innerHTML;
Expand Down Expand Up @@ -520,18 +534,3 @@ export const dropWhile = (xs, f) => {
if (f(xs[0])) return dropWhile(xs.slice(1), f);
return xs;
};

//
export const disableMobileScroll = () => {
document.body.style.top = `-${window.scrollY}px`;
document.body.classList.add('disable-ios-scroll');
}

export const enableMobileScroll = () => {
if (!document.body.style.top) return;
const y = Math.abs(parseInt(document.body.style.top, 10));
if (y === NaN) return;
document.body.classList.remove('disable-ios-scroll');
document.body.style.removeProperty('top');
window.scroll(0, y || 0);
}

0 comments on commit be22936

Please sign in to comment.