Skip to content

Instantly share code, notes, and snippets.

@bulini
Created October 7, 2017 17:36
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 bulini/80a191623a0f377fe950847dc32d0716 to your computer and use it in GitHub Desktop.
Save bulini/80a191623a0f377fe950847dc32d0716 to your computer and use it in GitHub Desktop.
var offset = $("#filter-search").offset();
var topPadding = 100;
$(window).scroll(function() {
if ($(window).scrollTop() > offset.top) {
$("#filter-search").stop().animate({
marginTop: $(window).scrollTop() - offset.top + topPadding
});
} else {
$("#filter-search").stop().animate({
marginTop: 0
});
};
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment