Skip to content

Instantly share code, notes, and snippets.

@overwine
Last active August 29, 2015 14:26
Show Gist options
  • Select an option

  • Save overwine/d5cf59ab2a907b9cebde to your computer and use it in GitHub Desktop.

Select an option

Save overwine/d5cf59ab2a907b9cebde to your computer and use it in GitHub Desktop.
Scroll up and scroll down detection + animation
var lastScrollTop = 0;
console.log(lastScrollTop);
$(window).scroll(function(event){
var currentScrollTop = $(window).scrollTop();
if (currentScrollTop > lastScrollTop){
$('.top-filter').animate({
top: "-20px",
}, 1000);
//$('body').addClass('has-scrolled')
console.log(currentScrollTop);
} else if (currentScrollTop <= lastScrollTop) {
$('.top-filter').animate({
top: "147px",
}, 1000);
//$('body').removeClass('has-scrolled')
}
lastScrollTop = currentScrollTop;
console.log(currentScrollTop)
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment