Skip to content

Instantly share code, notes, and snippets.

@gerbenvandijk
Created November 19, 2013 10:07
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 gerbenvandijk/7543128 to your computer and use it in GitHub Desktop.
Save gerbenvandijk/7543128 to your computer and use it in GitHub Desktop.
Simple jQuery script to make part(s) of the site sticky when scrolled beyond a certain point.
// sticky scroll function
function ScrollNav() {
if ($(document).scrollTop() > 0) {
} else {
}
}
// initiate the code on load for when a user has scrolled before and refreshed the page
ScrollNav();
// initiate the code on scroll. note that this doest work nicely on iOs, but there is no viable workaround for this yet.
$(window).scroll(function(){
ScrollNav();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment