Skip to content

Instantly share code, notes, and snippets.

@bulini
Created October 7, 2017 17:36
Show Gist options
  • 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