移动端处理图片懒加载
//照片墙图片懒加载 function lazyLondImg() { var lazyImgs = $(".js-lazyLoad"), //需要懒加载的图片 lazyIndex = 0, //加载到的图片index curHeight = document.documentElement.clientHeight, //初始页面高度 myY = 0, tmpY = 0; function showImg() { for(var i = lazyIndex; i < lazyImgs.length; i++){ var curImgEle = lazyImgs[i]; var imgTop = curImgEle.parentNode.offsetTop; if((imgTop-$("body").scrollTop()) <= curHeight + 10){ // 页面初始化加载浏览器可见区域图片 lazyIndex = i; curImgEle.setAttribute("src",curImgEle.getAttribute("datasrc")); }else{ break; } } } showImg(); document.body.addEventListener("touchstart",function (event) { myY = event.touches[0].clientY; }); document.body.addEventListener("touchmove",function (event) { tmpY = event.touches[0].clientY; if(myY - tmpY >= 10){ showImg(); } }); document.body.addEventListener("touchend",function (event) { showImg(); }); }