国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁(yè) > 編程 > JavaScript > 正文

iscroll動(dòng)態(tài)加載數(shù)據(jù)完美解決方法

2019-11-19 16:03:13
字體:
供稿:網(wǎng)友

本文實(shí)例為大家分享了iscroll動(dòng)態(tài)加載數(shù)據(jù)的具體代碼,供大家參考,具體內(nèi)容如下

<div id="wrapper" class="margin-b90">    <div id="scroller">      <div id="pullDown">        <span class="pullDownLabel" style="text-align: center;">加載中...</span>      </div>      <div class="sps_itemBox ">        <div class="list_show">          <ul id="ulList"></ul>        </div>      </div>      <div id="pullUp">        <span class="pullUpLabel" style="text-align: center;">上拉加載...</span>      </div>    </div>  </div>

js.

// iScroll 滾動(dòng)條/上拉刷新/下拉加載var myScroll,pullDownEl,pullDownOffset,pullUpEl,pullUpOffset;function loaded() {pullDownEl = document.getElementById('pullDown');pullDownOffset = pullDownEl.offsetHeight;pullUpEl = document.getElementById('pullUp');pullUpOffset = pullUpEl.offsetHeight;myScroll = new iScroll('wrapper', {useTransition: false,topOffset: pullDownOffset,btnOffset: pullUpOffset,hideScrollbar: true,fadeScrollbar: true,onRefresh: function () {if (pullDownEl.className.match('loading')) {pullDownEl.className = '';//pullDownEl.querySelector('.pullDownLabel').innerHTML = '下拉刷新...';pullDownEl.querySelector('.pullDownLabel').innerHTML = '數(shù)據(jù)更新時(shí)間:' + updateDatetime;} else if (pullUpEl.className.match('loading')) {pullUpEl.className = '';pullUpEl.querySelector('.pullUpLabel').innerHTML = '上拉加載...';}},onScrollMove: function () {if (this.y > 5 && !pullDownEl.className.match('flip')) {pullDownEl.className = 'flip';//pullDownEl.querySelector('.pullDownLabel').innerHTML = '釋放刷新...';pullDownEl.querySelector('.pullDownLabel').innerHTML = '數(shù)據(jù)更新時(shí)間:' + updateDatetime;this.minScrollY = 0;} else if (this.y < 5 && pullDownEl.className.match('flip')) {pullDownEl.className = '';//pullDownEl.querySelector('.pullDownLabel').innerHTML = '下拉刷新...';pullDownEl.querySelector('.pullDownLabel').innerHTML = '數(shù)據(jù)更新時(shí)間:' + updateDatetime;this.minScrollY = -pullDownOffset;} else if (this.y < (this.maxScrollY - pullUpOffset - 40) && !pullUpEl.className.match('flip')) {pullUpEl.className = 'flip';pullUpEl.querySelector('.pullUpLabel').innerHTML = '釋放加載...';this.maxScrollY = this.maxScrollY - pullUpOffset;}//else if (this.y > (this.maxScrollY - pullUpOffset) && pullUpEl.className.match('flip')) {// pullUpEl.className = '';// pullUpEl.querySelector('.pullUpLabel').innerHTML = '上拉加載...';// //this.maxScrollY = pullUpOffset;//}},onScrollEnd: function () {if (pullDownEl.className.match('flip')) {pullDownEl.className = 'loading';//pullDownEl.querySelector('.pullDownLabel').innerHTML = '數(shù)據(jù)刷新中...';pullDownEl.querySelector('.pullDownLabel').innerHTML = '數(shù)據(jù)更新時(shí)間:' + updateDatetime;myScroll.refresh();} else if (pullUpEl.className.match('flip')) { pullUpEl.className = 'loading';pullUpEl.querySelector('.pullUpLabel').innerHTML = '數(shù)據(jù)加載中...';setTimeout(function () { myScroll.refresh(); }, 3000);}}});}document.addEventListener('touchmove', function (e) { e.preventDefault(); }, false);document.addEventListener('DOMContentLoaded', function () { setTimeout(loaded, 200); }, false);

css

/* iScroll */#wrapper{width:100%; position:absolute; top:0; bottom:0; z-index:1; overflow:hidden;}#scroller{  width:100%; position:absolute; z-index:1;  -webkit-touch-callout:none; -webkit-tap-highlight-color:rgba(0,0,0,0);}#pullDown,#pullUp{padding:15px 0 15px 60px; font-size:14px; line-height:27px; color:#303030;}#pullDown{background:url(../images/loadBottom.png) no-repeat 30px center; background-size:27px 27px;}#pullUp{background:url(../images/loadTop.png) no-repeat 30px center; background-size:27px 27px;}#pullDown.flip{background:url(../images/loadTop.png) no-repeat 30px center; background-size:27px 27px;}#pullUp.flip{background:url(../images/loadBottom.png) no-repeat 30px center; background-size:27px 27px;}#pullDown.loading,#pullUp.loading{background:url(../images/loading.gif) no-repeat 30px center; background-size:25px 27px;}/* iScroll end */

以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持武林網(wǎng)。

發(fā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 寻乌县| 铜梁县| 崇明县| 苗栗市| 久治县| 秦皇岛市| 木兰县| 扶绥县| 淄博市| 思南县| 天等县| 建瓯市| 莱州市| 星子县| 龙岩市| 监利县| 嘉定区| 泾源县| 杭州市| 林周县| 桂阳县| 九龙坡区| 崇仁县| 黑龙江省| 行唐县| 赣州市| 慈利县| 成安县| 项城市| 神农架林区| 雷州市| 航空| 昌平区| 贵德县| 荣昌县| 辽阳市| 昭苏县| 五原县| 奉化市| 太和县| 小金县|