Skip to content

Instantly share code, notes, and snippets.

@ErikFontanel
Created November 25, 2015 10:10
Show Gist options
  • Save ErikFontanel/b695f2217655663f3f5c to your computer and use it in GitHub Desktop.
Save ErikFontanel/b695f2217655663f3f5c to your computer and use it in GitHub Desktop.
Very simple auto hiding sticky header
$(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