Created
November 25, 2015 10:10
-
-
Save ErikFontanel/b695f2217655663f3f5c to your computer and use it in GitHub Desktop.
Very simple auto hiding sticky header
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
$(document).ready(function() { | |
var initialOffset = -1; | |
var headerHeight = $("#global__header").outerHeight(); | |
$(window).scroll(function(event) { | |
var scrollOffset = $(this).scrollTop(); | |
scrollOffset > initialOffset && scrollOffset > headerHeight ? $("#global__header").addClass("hide-header") : initialOffset > scrollOffset && $("#global__header").removeClass("hide-header"), | |
initialOffset = scrollOffset | |
} | |
) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment