Skip to content

Instantly share code, notes, and snippets.

@cziem
Created November 12, 2018 10:24
Show Gist options
  • Select an option

  • Save cziem/c30b9bc655d3619dfe753403239ad2b9 to your computer and use it in GitHub Desktop.

Select an option

Save cziem/c30b9bc655d3619dfe753403239ad2b9 to your computer and use it in GitHub Desktop.
a full version of the main.js file
const nav = document.querySelector('nav')
let navTop = nav.offsetTop
const stickyNav = () => {
if (window.scrollY >= navTop) {
document.body.classList.add('fixed_nav')
} else {
document.body.classList.remove('fixed_nav')
}
}
window.addEventListener('scroll', stickyNav)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment