Created
June 7, 2017 20:43
-
-
Save codeZoner/9c03f2f70b67356a239965387ef99ac0 to your computer and use it in GitHub Desktop.
Check up or down scrolls using JQUERY
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Check up or down scrolls | |
function isScrollTopOrDown(){ | |
var lastScrollTop = 0, delta = 5; | |
$(window).scroll(function(){ | |
var nowScrollTop = $(this).scrollTop(); | |
if(Math.abs(lastScrollTop - nowScrollTop) >= delta){ | |
if (nowScrollTop > lastScrollTop){ | |
if(debug){ | |
// console.log('Scrolling Down'); | |
// console.log(isElementInViewport('.home-ask-section')); | |
} | |
isScrollDown = 1; //Scrolling Down | |
} else { | |
// ACTION ON | |
// SCROLLING UP | |
isScrollDown = 0; //Scrolling up | |
} | |
lastScrollTop = nowScrollTop; | |
} | |
}); | |
return isScrollDown; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment