当用户向上推时滚动顶部小于0时,我能检测吗? (喜欢facebook app reload)
到目前为止,这是我的代码构思:
window.onscroll = function (e) {
scrollTop = hasOffset ? window.pageYOffset : docBody.scrollTop;
detect_pushUp(scrollTop);
};
var push_up_check = true;
function detect_pushUp(scrollPosition) {
if(scrollPosition === 0 && !push_up_check) {
push_up_check = true;
} else if(scrollPosition === 0 && push_up_check) {
location.reload(true);
} else {
push_up_check = false;
}
}
这项工作正常,但有什么好主意吗?检测这样的事情?