I am trying to run a function once the user has scrolled up 100px and another function when they scroll down (any number of pixels) from there current location. So if the user scrolls half way down a page and then starts to scroll up i need a function to run once they have scrolled up 100px from the current stored scrollTop value.
If the user was 700px down the page and they started to scroll up I need a function to run when they hit 600px. This should be dynamic from where ever the user is down the page.
As a starting point i have:
var lastScrollTop = 0;
$(window).scroll(function(event){
var st = $(this).scrollTop();
if (st > lastScrollTop){
// Scrolling down
} else {
// Scrolling up
}
lastScrollTop = st;
});
Thanks