Skip to content

Instantly share code, notes, and snippets.

@uryu-myao
Created November 6, 2018 09:25
Show Gist options
  • Save uryu-myao/df19ff1b5c85d4a4f1ac8f2b7727b944 to your computer and use it in GitHub Desktop.
Save uryu-myao/df19ff1b5c85d4a4f1ac8f2b7727b944 to your computer and use it in GitHub Desktop.
HEADER SCROLLED
const HEADER = (function () {
function scrollingSwitch() {
let Page = document.getElementById('whole'),
headerHeight = 185
if (document.body.scrollTop >= headerHeight ||
document.documentElement.scrollTop > headerHeight) {
Page.classList.add('headerPoint')
} else {
Page.classList.remove('headerPoint')
}
}
let bindActions = function () {
window.onscroll = function () {
scrollingSwitch()
}
}
let init = function () {
bindActions()
}
return { init: init }
}());
HEADER.init();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment