Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save manfromanotherland/32d47071b877263e06437892bd293f1a to your computer and use it in GitHub Desktop.
Save manfromanotherland/32d47071b877263e06437892bd293f1a to your computer and use it in GitHub Desktop.
By Roberto O'Breno
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