Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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