Pages

2012年7月3日 星期二

How can UP/DOWN scroll be distinguished??

he easiest way for me to tell was...
var tempScrollTop, currentScrollTop = 0;
$("#div").scroll(function(){
currentScrollTop = $("#div").scrollTop();
if (tempScrollTop < currentScrollTop )
//scrolling down
else if (tempScrollTop > currentScrollTop )
//scrolling up
tempScrollTop = currentScrollTop;
}
This works with mousewheel, up/down arrows, and slidebar

沒有留言:

張貼留言