Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@DarrylD
Last active December 27, 2015 12:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DarrylD/7323966 to your computer and use it in GitHub Desktop.
Save DarrylD/7323966 to your computer and use it in GitHub Desktop.
Simple fixed header after trigger point
(function(){
var triggerElement = $(".container") //element to he used to trigger the fixed header
, header = $(".header") //element of header
, stickyClass = "stickit" // class to be used to give the fixed header a fixed position
$(window).scroll(function(){
var offset = 0,sticky = false,top = $(window).scrollTop();
if (triggerElement.offset().top < top) {
header.addClass(stickyClass)
sticky = true;
} else {
header.removeClass(stickyClass).removeAttr('style');
}
});
})()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment