我想连续运行窗口滚动功能,以检测用户是向下滚动还是向上滚动。我如何使用JS来实现这一点呢? function doWork(){
window.onscroll = function(e) {
// print "false" if direction is down and "true" if up
console.log(this.oldScroll > this.scrollY);
this.oldScroll = this.scrollY;
}}
var timer = setInterval(doWork, 0);