Last active
December 27, 2015 12:09
-
-
Save DarrylD/7323966 to your computer and use it in GitHub Desktop.
Simple fixed header after trigger point
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
(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