imgLoading.js 669 B

12
  1. window.onload=function(){for(var c=document.querySelectorAll("img[data-src]"),b=0;b<c.length;b++)c[b].style.opacity="0";Limg()};window.onscroll=function(){0!==document.querySelectorAll("img[data-src]").length&&(Limg(),this.console.log("\u52a0\u8f7d..."))};
  2. function Limg(){var c=document.documentElement.clientHeight,b=document.querySelectorAll("img[data-src]");Array.prototype.forEach.call(b,function(a,d){""!==a.getAttribute("data-src")&&(d=a.getBoundingClientRect(),0<=d.bottom&&d.top<c&&function(){var f=new Image;f.src=a.getAttribute("data-src");a.src=f.src;var e=0;setInterval(function(){e+=.2;1>=e&&(a.style.opacity=e)},100);a.removeAttribute("data-src")}())})};