//获取滚动条的高度
function getScrollTop() {
var scrollTop = 0;
if (document.documentElement && document.documentElement.scrollTop) {
scrollTop = document.documentElement.scrollTop;
} else if (document.body) {
scrollTop = document.body.scrollTop;
}
return scrollTop;
}
var scrollFunc = function (e) {
//判断条件,根据当时情况是否执行
if (app.hasLoad() && false == app.isLocked) {
//判断滚动条是否在最底部
if ($(document).scrollTop() >= $(document).height() - $(window).height()) {
e = e || window.event;
//执行查询方法
var loadData = function () {
if (Math.ceil(app.total / app.size) > app.page) {
app.isLocked = true;
Query(++app.page, app.size, function () {
app.isLocked = false;
});
}
}
if (e.wheelDelta) {//Google滑轮事件
if (e.wheelDelta < 0) { //当滑轮向下滚动时
loadData();
}
} else if (e.detail) { //Firefox滑轮事件
if (e.detail < 0) { //当滑轮向下滚动时
loadData();
}
}
}
}
}
if (document.addEventListener) {
document.addEventListener('DOMMouseScroll', scrollFunc, false);
}
//滚动条监听
window.onmousewheel = document.onmousewheel = scrollFunc;