css 部分睛廊, 主要是 絕對定位 滑動區(qū)域 和 底部區(qū)域
<!-- 下拉加載樣式-->
footer {
height: 52px;
width: 100%;
min-width: 320px;
background: #000;
text-align: center;
color: #fff;
font-size: 1.2rem;
line-height: 52px;
position: absolute;
bottom: 0;
}
#wrapper {
margin: auto auto auto auto;
width: 100%;
min-width: 320px;
position: absolute;
left: 0;
overflow: hidden;
z-index: 1;
background-color: #fff;
height: 100%;
/* 防止本機Windows上的觸摸事件 */
-ms-touch-action: none;
/* 防止callout tap-hold和文本的選擇 */
-webkit-touch-callout: none;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
/* 防止文本調(diào)整取向變化對web應用程序很有用 */
-webkit-text-size-adjust: none;
-moz-text-size-adjust: none;
-ms-text-size-adjust: none;
-o-text-size-adjust: none;
text-size-adjust: none;
bottom: 0px;
height: 83%;
}
.pull-loading {
text-align: center;
height: 20px;
line-height: 20px;
align-items: center;
justify-content: center;
bottom: 0%;
z-index: 99;
position: absolute;
margin-left: 44%;
color: #414141;
}
html部分 warpper 是觸發(fā)區(qū)域, scroller 循環(huán)加載的 pull-loading 是底部
<div id="wrapper">
<div id="scroller">
</div>
<div class="pull-loading">
</div>
</div>
js 部分 pullOnLoad(); 這個是 ajax 上啦完成 要加載的東西
var handle = 0;
var biaozhu = '';
var myscroll = new iScroll("wrapper", {
vScrollbar: false,
useTransition: true,
onScrollMove: function () { //拉動時
if (this.y > 5 && biaozhu !='flip') {
biaozhu = 'flip';
$(".pull-loading").html("1");
$(".pull-loading").addClass("loading");
this.minScrollY = 0;
} else if (this.y < 5 && biaozhu =='flip') {
biaozhu = '';
$(".pull-loading").html("2");
$(".pull-loading").addClass("loading");
} else if (this.y < (this.maxScrollY - 5) && biaozhu !='flip') {
biaozhu = '';
handle = 1;
$(".pull-loading").html("3");
$(".pull-loading").addClass("loading");
this.maxScrollY = this.maxScrollY;
} else if (this.y > (this.maxScrollY + 5) && biaozhu =='flip') {
biaozhu = '';
handle = 2;
$(".pull-loading").html("4");
$(".pull-loading").addClass("loading");
}
},
onScrollEnd: function () { //拉動結束時
if (handle == 1) {
pullOnLoad();
}else if(handle == 2) {
window.location.reload()
}
},
});
接入 jq 和iscroll.js