图片懒加载记录

// 图片处理
$.each(data.imgList, function(i, n) {
	body.contents().find('#panel_imgList').append(' 0) {
				// 获取科室区域高度:
				var wheight = body.contents().find("#panel_imgList").height();
				// 存放待删除的索引:
				var loadeIndex = [];
				// 循环处理数组的每个img元素
				$.each(tcymjcmJmqr._lazyImgs.length > 0) {
					// 判断是否在可视范围内:
					if($(n).offset().top - wtop < wheight) {
						// 设置src属性:
						$(n).attr('src', $(n).attr('data-src'));
						// 添加到待删除数组:
						loadedIndex.unshift(i);
					}
				})
				if(loadedIndex.length > 0) {
					tcymjcmJmpr._lazyImgs.splice(0, loadedIndex.length);
				}
			}
	})
	tcymjcmJmpr._lazyImgs = body.contents().find('img[data-src]');
	body.contents().find('#panel_imgList').scroll();
})

你可能感兴趣的:(错题集)