2024-06-21 16:57:39 +00:00
|
|
|
//Nav slide in logic
|
|
|
|
|
2024-06-20 22:15:11 +00:00
|
|
|
const nav = document.querySelector('.st-nav');
|
2024-06-24 20:59:45 +00:00
|
|
|
const openNavButton = document.querySelector('.st-open-nav');
|
|
|
|
const closeNavButton = document.querySelector('.st-close-nav');
|
2024-06-20 22:15:11 +00:00
|
|
|
|
2024-06-24 20:59:45 +00:00
|
|
|
openNavButton.addEventListener('click', () => {
|
2024-06-20 22:15:11 +00:00
|
|
|
nav.classList.add('st-nav-is-open');
|
|
|
|
});
|
|
|
|
|
2024-06-24 20:59:45 +00:00
|
|
|
closeNavButton.addEventListener('click', () => {
|
2024-06-20 22:15:11 +00:00
|
|
|
nav.classList.remove('st-nav-is-open');
|
|
|
|
});
|
|
|
|
|
2024-06-24 20:59:45 +00:00
|
|
|
//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');
|
|
|
|
});
|
|
|
|
|
2024-06-21 16:57:39 +00:00
|
|
|
//Sticky nav logic
|
|
|
|
|
|
|
|
const iconBar = document.querySelector('.st-header-icon-bar');
|
|
|
|
const siteTitle = document.querySelector('.st-site-title');
|
2024-06-21 20:56:00 +00:00
|
|
|
const header = document.querySelector('.st-header');
|
2024-06-20 22:15:11 +00:00
|
|
|
let lastScrollPosition = 0;
|
|
|
|
|
|
|
|
window.addEventListener('scroll', function(event) {
|
|
|
|
const scrollPosition = window.scrollY;
|
2024-06-21 16:57:39 +00:00
|
|
|
|
|
|
|
if(scrollPosition < 5) {
|
|
|
|
iconBar.classList.remove('st-icon-bar-sticky');
|
|
|
|
siteTitle.classList.remove('st-title-scrolled');
|
2024-06-21 21:09:21 +00:00
|
|
|
header.classList.remove('st-header-scrolled');
|
2024-06-21 16:57:39 +00:00
|
|
|
} else {
|
|
|
|
if(lastScrollPosition < 5) {
|
|
|
|
iconBar.classList.add('st-icon-bar-sticky');
|
|
|
|
siteTitle.classList.add('st-title-scrolled');
|
2024-06-21 20:56:00 +00:00
|
|
|
header.classList.add('st-header-scrolled');
|
2024-06-21 16:57:39 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-06-20 22:15:11 +00:00
|
|
|
lastScrollPosition = scrollPosition;
|
|
|
|
});
|