Reputation: 32823
I following code which works fine to find when user reaches to the bottom or top of the div while scrolling. However, now I want to find once the user is reached to the bottom/top of the div tag and he/she is still scrolling. I mean once user reaches to the bottom the find out if that user is still scrolling in bottom direction and if user reaches to the top the find out if he is still scrolling in up direction. How can I achieve this?
Here is the CODE
$('.scroll').on('scroll',checkScroll);
function checkScroll(e)
{
var elem = $(e.currentTarget);
if (elem[0].scrollHeight - elem.scrollTop() == elem.outerHeight())
{
console.log("bottom");
}
if (scrollBottom(elem) == elem.outerHeight())
{
console.log("top");
}
}
function scrollBottom(el)
{
return $( el ).scrollTop() + $( el ).height();
}
Upvotes: 0
Views: 124
Reputation: 10683
try this i have test only in chrome browser:-
$('.scroll').bind('mousewheel DOMMouseScroll', function(event){
var elem= $(this);
if (elem[0].scrollHeight - elem.scrollTop() == elem.outerHeight())
{
console.log("opps.. still scrolling");
}
});
Upvotes: 1