let lastScroll = 0;
const header = document.getElementById('nav');
const defaultOffset = 150;
const scrollPosition = () => window.pageYOffset || document.documentElement.scrollTop;
window.addEventListener('scroll', () => {
if(scrollPosition() > lastScroll && scrollPosition() > defaultOffset) {
header.classList.remove('header_fix')
}
else if (scrollPosition() < lastScroll) {
header.classList.add('header_fix');
}
lastScroll = scrollPosition();
});
let header = document.getElementById("nav");
window.addEventListener("scroll", () => {
let scrollPosition = window.pageYOffset;
if (scrollPosition > 150) header.classList.remove("header_fix");
else if (scrollPosition < 150) header.classList.add("header_fix");
});