Instantly share code, notes, and snippets.

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