Created
November 6, 2018 09:25
-
-
Save uryu-myao/df19ff1b5c85d4a4f1ac8f2b7727b944 to your computer and use it in GitHub Desktop.
HEADER SCROLLED
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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