//Global Variales const root = document.documentElement; // // ------------------------------------------------------------------ // // Fixed Header with Anchor Tag Adjustment // // Creation Date: 2/23/2021 // // Last Updated: 4/19/2023 // // Description: Makes the navigation sticky and alters where the anchor tags should land // // when clicked. Needs to be an ID for the anchor tag to work properly // // ------------------------------------------------------------------ // Determine if header is sticky let headerStyle = findHeaderStyle(); function findHeaderStyle () { const headerStyling = getComputedStyle(document.querySelector('.c-header')); const navStyling = getComputedStyle(document.querySelector('.c-topnav__navbar')); if (["sticky", "fixed"].includes(headerStyling.position) || ["sticky", "fixed"].includes(navStyling.position)) { return true; } else { return false; } } //If sticky, do the following on load if (headerStyle == true) { window.addEventListener("load", (event) => { moveNavBar(); headerOffset(); anchor(); }); // Run headerOffset when logo is done transitioning or if there is a displayname const findLogo = document.getElementById('agentLogo'); const findDisplayName = document.querySelector('.c-header .c-template__logo--displayName'); if(findLogo){ findLogo.addEventListener('transitionend', () => { headerOffset(); }); } else if (findDisplayName){ headerOffset(); } // Intersection Observer if (!('IntersectionObserver' in window) || !('IntersectionObserverEntry' in window) || !('intersectionRatio' in window.IntersectionObserverEntry.prototype)) { //On load, scroll, or resize. Do this. //Enable scrollDown feature ["load", "resize", "scroll"].forEach(function (evt) { window.addEventListener(evt, scrollDown); }); } else { //Resize header intersection observer document.querySelector("body").insertAdjacentHTML('afterbegin','