var load = {
|
init: function() {
|
if ($(".loading-more").length <= 0) {
|
return;
|
}
|
$(".loading-more").css("visibility", "hidden");
|
$(".loading-more").empty();
|
$(".loading-more").css("display", "flex");
|
$(".loading-more").css("justify-content", "center");
|
$(".loading-more").css("align-items", "center");
|
$(".loading-more").css("height", "0.8rem");
|
$(".loading-more").css("font-size", "0");
|
$(".loading-more").append("<div class='loading'>");
|
for (var i = 1; i < 13; i++) {
|
// alert('2');
|
$(".loading").append("<div><span class='k'></span><span class='s'></span></div>");
|
}
|
$(".loading-more").append(
|
"<div class='notifyContent' style='display:inline;font-size:0.3rem;margin-left:0.2rem;color:#999999'>正在加载更多数据</div>"
|
)
|
},
|
show: function(msg) {
|
if (msg != null && msg.length > 0)
|
$(".loading-more").find("div").eq(1).html(msg);
|
$(".loading-more").css("visibility", "visible");
|
},
|
hidden: function() {
|
$(".loading-more").css("visibility", "hidden");
|
},
|
isLoading: function() {
|
var visibility = $(".loading-more").css("visibility");
|
if ("hidden" == visibility)
|
return false;
|
else
|
return true;
|
},
|
noMore: function() {
|
$(".loading-more .notifyContent").html("没有更多了");
|
$(".loading-more").find(".loading").css("display", "none");
|
$(".loading-more").css("visibility", "visible");
|
},
|
showMore: function(element, callBack) {
|
if (Math.abs(load.getScrollHeight() - load.getDocumentTop() - load.getWindowHeight()) < 10) {
|
if (load.isLoading())
|
return;
|
load.show();
|
setTimeout(function() {
|
callBack();
|
}, 300);
|
}
|
},
|
getDocumentTop: function() {
|
var scrollTop = 0,
|
bodyScrollTop = 0,
|
documentScrollTop = 0;
|
if (document.body) {
|
bodyScrollTop = document.body.scrollTop;
|
}
|
if (document.documentElement) {
|
documentScrollTop = document.documentElement.scrollTop;
|
}
|
scrollTop = (bodyScrollTop - documentScrollTop > 0) ? bodyScrollTop : documentScrollTop;
|
console.log("scrollTop:" + scrollTop);
|
return scrollTop;
|
},
|
getWindowHeight: function() {
|
var windowHeight = 0;
|
if (document.compatMode == "CSS1Compat") {
|
windowHeight = document.documentElement.clientHeight;
|
} else {
|
windowHeight = document.body.clientHeight;
|
}
|
console.log("windowHeight:" + windowHeight);
|
return windowHeight;
|
},
|
getScrollHeight: function() {
|
var scrollHeight = 0,
|
bodyScrollHeight = 0,
|
documentScrollHeight = 0;
|
if (document.body) {
|
bodyScrollHeight = document.body.scrollHeight;
|
}
|
if (document.documentElement) {
|
documentScrollHeight = document.documentElement.scrollHeight;
|
}
|
scrollHeight = (bodyScrollHeight - documentScrollHeight > 0) ? bodyScrollHeight : documentScrollHeight;
|
console.log("scrollHeight:" + scrollHeight);
|
return scrollHeight;
|
}
|
};
|
load.init();
|