Created
December 19, 2016 04:21
-
-
Save rjfranco/774a033f6f3283b02d1366e0f3448070 to your computer and use it in GitHub Desktop.
Function to watch for scroll position and apply class
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
// Depends on JQ | |
window.addEventListener('scroll', function(e){ | |
var distanceY = window.pageYOffset || document.documentElement.scrollTop, | |
transitionPoint = 500, | |
$header = $(".fixed-header"); | |
if (distanceY > transitionPoint) { | |
$header.addClass("smaller"); | |
} else { | |
$header.removeClass("smaller"); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment