diff --git a/libs/blocks/global-navigation/global-navigation.js b/libs/blocks/global-navigation/global-navigation.js index bccade01f1..bba4fc4894 100644 --- a/libs/blocks/global-navigation/global-navigation.js +++ b/libs/blocks/global-navigation/global-navigation.js @@ -6,6 +6,7 @@ import { loadIms, decorateLinks, loadScript, + getGnavSource, } from '../../utils/utils.js'; import { closeAllDropdowns, @@ -43,7 +44,6 @@ import { closeAllTabs, disableMobileScroll, enableMobileScroll, - getGnavSource, } from './utilities/utilities.js'; import { getFedsPlaceholderConfig } from '../../utils/federated.js'; diff --git a/libs/blocks/global-navigation/utilities/utilities.js b/libs/blocks/global-navigation/utilities/utilities.js index 4d9ab7bc1f..dd808c0a56 100644 --- a/libs/blocks/global-navigation/utilities/utilities.js +++ b/libs/blocks/global-navigation/utilities/utilities.js @@ -545,18 +545,10 @@ export const dropWhile = (xs, f) => { return xs; }; -export async function getGnavSource() { - const { locale, dynamicNavKey } = getConfig(); - let url = getMetadata('gnav-source') || `${locale.contentRoot}/gnav`; - if (dynamicNavKey) { - const { default: dynamicNav } = await import('../features/dynamic-navigation/dynamic-navigation.js'); - url = dynamicNav(url, dynamicNavKey); - } - return url; -} - -export async function isLocalNav() { - const gnavSource = await getGnavSource(); +export function isLocalNav() { + if (isDesktop.matches) return false; + const { locale } = getConfig(); + const gnavSource = getMetadata('gnav-source') || `${locale.contentRoot}/gnav`; const newNavEnabled = new URLSearchParams(window.location.search).get('newNav') || getMetadata('mobile-gnav-v2') !== 'off'; return gnavSource.split('/').pop().startsWith('localnav-') && newNavEnabled; } diff --git a/libs/blocks/section-metadata/sticky-section.js b/libs/blocks/section-metadata/sticky-section.js index 0232426e26..92a36813e4 100644 --- a/libs/blocks/section-metadata/sticky-section.js +++ b/libs/blocks/section-metadata/sticky-section.js @@ -1,17 +1,9 @@ import { createTag } from '../../utils/utils.js'; import { getMetadata, getDelayTime } from './section-metadata.js'; +import { getGnavHeight } from '../global-navigation/utilities/utilities.js'; function handleTopHeight(section) { - let topHeight = document.querySelector('header')?.offsetHeight ?? 0; - const localNav = document.querySelector('.feds-localnav'); - const fedsPromo = document.querySelector('.feds-promo-wrapper'); - if (localNav && localNav.offsetHeight > 0) { - topHeight = localNav.offsetHeight; - } - if (fedsPromo) { - topHeight += fedsPromo.offsetHeight; - } - + const topHeight = getGnavHeight(); section.style.top = `${topHeight}px`; } diff --git a/libs/mep/ace0861/section-metadata/sticky-section.js b/libs/mep/ace0861/section-metadata/sticky-section.js index a54f8518c1..230d34226e 100644 --- a/libs/mep/ace0861/section-metadata/sticky-section.js +++ b/libs/mep/ace0861/section-metadata/sticky-section.js @@ -1,17 +1,9 @@ import { createTag } from '../../../utils/utils.js'; import { getMetadata, getDelayTime } from './section-metadata.js'; +import { getGnavHeight } from '../../../blocks/global-navigation/utilities/utilities.js'; function handleTopHeight(section) { - let topHeight = document.querySelector('header').offsetHeight; - const localNav = document.querySelector('.feds-localnav'); - const fedsPromo = document.querySelector('.feds-promo-wrapper'); - if (localNav) { - topHeight = localNav.offsetHeight; - } - if (fedsPromo) { - topHeight += fedsPromo.offsetHeight; - } - + const topHeight = getGnavHeight(); section.style.top = `${topHeight}px`; }