| 1 |
!function(){"use strict";var e=e||{},t={_ticking:!1,check:function(){if(!t._ticking){t._ticking=!0,"undefined"==typeof t.threshold&&("undefined"!=typeof e.threshold?t.threshold=parseInt(e.threshold):t.threshold=200);var n=document.documentElement.clientHeight||body.clientHeight,a=!1,i=document.getElementsByClassName("lazy-hidden");[].forEach.call(i,(function(e,i,c){var d=e.getBoundingClientRect();n-d.top+t.threshold>0&&(t.show(e),a=!0)})),t._ticking=!1,a&&t.check()}},show:function(e){e.className=e.className.replace(/(?:^|\s)lazy-hidden(?!\S)/g,""),e.addEventListener("load",(function(){e.className+=" lazy-loaded",t.customEvent(e,"lazyloaded")}),!1);var n=e.getAttribute("data-lazy-type");if("image"==n)null!=e.getAttribute("data-lazy-srcset")&&e.setAttribute("srcset",e.getAttribute("data-lazy-srcset")),null!=e.getAttribute("data-lazy-sizes")&&e.setAttribute("sizes",e.getAttribute("data-lazy-sizes")),e.setAttribute("src",e.getAttribute("data-lazy-src"));else if("iframe"==n){var a=e.getAttribute("data-lazy-src"),i=document.createElement("div");i.innerHTML=a;var c=i.firstChild;e.parentNode.replaceChild(c,e)}},customEvent:function(e,t){var n;document.createEvent?(n=document.createEvent("HTMLEvents")).initEvent(t,!0,!0):(n=document.createEventObject()).eventType=t,n.eventName=t,document.createEvent?e.dispatchEvent(n):e.fireEvent("on"+n.eventType,n)}};window.addEventListener("load",t.check,!1),window.addEventListener("scroll",t.check,!1),window.addEventListener("resize",t.check,!1),document.getElementsByTagName("body").item(0).addEventListener("post-load",t.check,!1)}(); |