2024-07-01 20:18:30 +00:00
|
|
|
//Nav slide in logic
|
|
|
|
|
|
|
|
const nav = document.querySelector('.st-nav');
|
|
|
|
const openNavButton = document.querySelector('.st-open-nav');
|
|
|
|
const closeNavButton = document.querySelector('.st-close-nav');
|
|
|
|
|
|
|
|
openNavButton.addEventListener('click', () => {
|
|
|
|
nav.classList.add('st-nav-is-open');
|
|
|
|
});
|
|
|
|
|
|
|
|
closeNavButton.addEventListener('click', () => {
|
|
|
|
nav.classList.remove('st-nav-is-open');
|
|
|
|
});
|
|
|
|
|
|
|
|
//Search slide logic
|
|
|
|
|
|
|
|
const searchOverlay = document.querySelector('.st-search-overlay');
|
|
|
|
const openSearchButton = document.querySelector('.st-open-search');
|
|
|
|
const closeSearchButton = document.querySelector('.st-close-search');
|
|
|
|
|
|
|
|
openSearchButton.addEventListener('click', () => {
|
|
|
|
searchOverlay.classList.add('st-search-is-open');
|
|
|
|
});
|
|
|
|
|
|
|
|
closeSearchButton.addEventListener('click', () => {
|
|
|
|
searchOverlay.classList.remove('st-search-is-open');
|
|
|
|
});
|
|
|
|
|
|
|
|
//Sticky nav logic
|
|
|
|
|
|
|
|
const iconBar = document.querySelector('.st-header-icon-bar');
|
|
|
|
const siteTitle = document.querySelector('.st-site-title');
|
2024-07-22 19:41:07 +00:00
|
|
|
const siteTitleBall = document.querySelector('.st-site-title__ball');
|
2024-07-01 20:18:30 +00:00
|
|
|
const header = document.querySelector('.st-header');
|
2024-07-23 21:31:45 +00:00
|
|
|
const topper = document.querySelector('.st-article-section-topper');
|
2024-07-24 19:17:49 +00:00
|
|
|
const desktopNavLinks = document.querySelector('.st-desktop-nav-links');
|
2024-08-16 22:45:35 +00:00
|
|
|
const mainTitleLink = document.querySelector('.st-site-title-link__main-title'); // cache link, remove href when scrolled
|
|
|
|
const mainTitleBallLink = document.querySelector('.st-site-title-link__ball');
|
|
|
|
const siteTitleGrid = document.querySelector('.st-site-title-grid');
|
|
|
|
const hiddenHomeHeaderLink = document.querySelector('.st-hidden-home-header-link');
|
2024-07-01 20:18:30 +00:00
|
|
|
let lastScrollPosition = 0;
|
2024-07-22 19:41:07 +00:00
|
|
|
const scrollDepthActivationPoint = 80;
|
2024-07-01 20:18:30 +00:00
|
|
|
|
|
|
|
window.addEventListener('scroll', function(event) {
|
2024-08-15 23:52:06 +00:00
|
|
|
setHeaderClasses()
|
|
|
|
});
|
|
|
|
|
|
|
|
window.addEventListener('load', function(event) {
|
|
|
|
setHeaderClasses()
|
|
|
|
})
|
|
|
|
|
|
|
|
function setHeaderClasses() {
|
2024-07-01 20:18:30 +00:00
|
|
|
const scrollPosition = window.scrollY;
|
|
|
|
|
2024-07-02 20:45:52 +00:00
|
|
|
if(scrollPosition < scrollDepthActivationPoint) {
|
2024-07-01 20:18:30 +00:00
|
|
|
iconBar.classList.remove('st-icon-bar-sticky');
|
|
|
|
siteTitle.classList.remove('st-title-scrolled');
|
2024-08-16 22:45:35 +00:00
|
|
|
siteTitleGrid.classList.remove('st-disable-link', 'st-send-to-back');
|
2024-07-01 20:18:30 +00:00
|
|
|
header.classList.remove('st-header-scrolled');
|
2024-07-22 19:41:07 +00:00
|
|
|
siteTitleBall.classList.remove('st-title-scrolled__ball');
|
2024-07-23 21:31:45 +00:00
|
|
|
topper.classList.remove('st-article-section-topper-scrolled');
|
2024-07-24 19:17:49 +00:00
|
|
|
desktopNavLinks.classList.remove('st-desktop-nav-links-scrolled');
|
2024-08-16 22:45:35 +00:00
|
|
|
hiddenHomeHeaderLink.classList.remove('st-hidden-home-header-link-scrolled');
|
2024-07-01 20:18:30 +00:00
|
|
|
} else {
|
2024-07-02 20:45:52 +00:00
|
|
|
if(lastScrollPosition < scrollDepthActivationPoint) {
|
2024-07-01 20:18:30 +00:00
|
|
|
iconBar.classList.add('st-icon-bar-sticky');
|
|
|
|
siteTitle.classList.add('st-title-scrolled');
|
2024-08-16 22:45:35 +00:00
|
|
|
siteTitleGrid.classList.add('st-disable-link', 'st-send-to-back');
|
2024-07-01 20:18:30 +00:00
|
|
|
header.classList.add('st-header-scrolled');
|
2024-07-22 19:41:07 +00:00
|
|
|
siteTitleBall.classList.add('st-title-scrolled__ball');
|
2024-07-23 21:31:45 +00:00
|
|
|
topper.classList.add('st-article-section-topper-scrolled');
|
2024-07-24 19:17:49 +00:00
|
|
|
desktopNavLinks.classList.add('st-desktop-nav-links-scrolled');
|
2024-08-16 22:45:35 +00:00
|
|
|
hiddenHomeHeaderLink.classList.add('st-hidden-home-header-link-scrolled');
|
2024-07-01 20:18:30 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
lastScrollPosition = scrollPosition;
|
2024-08-15 23:52:06 +00:00
|
|
|
}
|
2024-07-24 18:29:01 +00:00
|
|
|
|
|
|
|
const navItems = document.querySelectorAll('.st-header-icon-bar__item');
|