如何在下拉刷新的时候触发懒加载
1个回答
展开全部
JS代码补充:
mui.init();
(function($) {
//阻尼系数
var deceleration = mui.os.ios?0.003:0.0009;
$('.mui-scroll-wrapper').scroll({
bounce: false,
indicators: true, //是否显示滚动条
deceleration:deceleration
});
$.ready(function() {
//循环初始化所有下拉刷新,上拉加载。
$.each(document.querySelectorAll('.mui-slider-group .mui-scroll'), function(index, pullRefreshEl) {
$(pullRefreshEl).pullToRefresh({
down: {
callback: function() {
var self = this;
setTimeout(function() {
var ul = self.element.querySelector('.mui-table-view');
ul.insertBefore(createFragment(ul, index, 2, true), ul.firstChild);
self.endPullDownToRefresh();
}, 300);
}
},
up: {
callback: function() {
var self = this;
setTimeout(function() {
var ul = self.element.querySelector('.mui-table-view');
ul.appendChild(createFragment(ul, index, 10));
self.endPullUpToRefresh();
$(document).imageLazyload({
placeholder: '../images/60x60.gif'
});
}, 300);
}
}
});
});
var createFragment = function(ul, index, count, reverse) {
var length = ul.querySelectorAll('li').length;
var fragment = document.createDocumentFragment();
var li;
for (var i = 0; i < count; i++) {
for( var j = 1; j <= 3; j++ ){
li = document.createElement('li');
li.className = 'mui-table-view-cell mui-media mui-col-xs-4';
//li.innerHTML = '第' + (index + 1) + '个选项卡子项-' + (length + (reverse ? (count - i) : (i + 1)));
if( index == 0){
li.innerHTML = ' <a href="#"><img class="mui-media-object" data-lazyload="http://www.dcloud.io/hellomui/images/'+(j+1)+'.jpg?version='+Math.random()*1000+'"></a>';
}else{
li.innerHTML = '通告-' + (length + (reverse ? (count - i) : (i + 1)));
}
fragment.appendChild(li);
}
}
return fragment;
};
});
})(mui);
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询