Created
March 23, 2017 15:08
-
-
Save manfromanotherland/32d47071b877263e06437892bd293f1a to your computer and use it in GitHub Desktop.
By Roberto O'Breno
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
function header_change() { | |
window.addEventListener('scroll', function(e){ | |
var distanceY = window.pageYOffset || document.documentElement.scrollTop, | |
shrinkOn = 55, | |
//header = document.querySelector("header"); | |
header = document.getElementsByClassName("actual_header"); | |
if (distanceY > shrinkOn) { | |
classie.add(header,"smaller"); | |
// convert to new color and add apacity | |
classie.add(header,"change_background") | |
} else { | |
if (classie.has(header,"smaller")) { | |
classie.remove(header,"smaller"); | |
// convert back to orignal color and remove opacity change | |
classie.remove(header,"change_background") | |
} | |
} | |
}); | |
} | |
// Call the function when the web page loads | |
window.onload = header_change(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment