50projects50days/sticky-navigation/script.js
2020-11-17 14:00:55 -05:00

10 lines
251 B
JavaScript

const nav = document.querySelector('.nav')
window.addEventListener('scroll', fixNav)
function fixNav() {
if(window.scrollY > nav.offsetHeight + 150) {
nav.classList.add('active')
} else {
nav.classList.remove('active')
}
}