forked from aFarkas/lazysizes
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ls.unload.min.js
2 lines (2 loc) · 2.46 KB
/
ls.unload.min.js
1
2
/*! lazysizes - v4.0.2 */
!function(a,b){var c=function(){b(a.lazySizes),a.removeEventListener("lazyunveilread",c,!0)};b=b.bind(null,a,a.document),"object"==typeof module&&module.exports?b(require("lazysizes")):a.lazySizes?c():a.addEventListener("lazyunveilread",c,!0)}(window,function(a,b,c){"use strict";function d(){if(a.lazySizes&&!f){var h=b.documentElement,i=function(){var a,b=function(){j.checkElements(),a=!1};return function(){a||(a=!0,setTimeout(b,999))}}();e=c.cfg,removeEventListener("lazybeforeunveil",d),"unloadClass"in e||(e.unloadClass="lazyunload"),"unloadedClass"in e||(e.unloadedClass="lazyunloaded"),"unloadHidden"in e||(e.unloadHidden=!0),"emptySrc"in e||(e.emptySrc="data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw=="),"autoUnload"in e||(e.autoUnload=!0),"unloadPixelThreshold"in e||(e.unloadPixelThreshold=6e4),e.autoUnload&&h.addEventListener("load",function(a){a.target.naturalWidth*a.target.naturalHeight>e.unloadPixelThreshold&&a.target.className&&a.target.className.indexOf&&-1!=a.target.className.indexOf(lazySizesConfig.loadingClass)&&-1==a.target.className.indexOf(lazySizesConfig.preloadClass)&&c.aC(a.target,lazySizesConfig.unloadClass)},!0),c.unloader=j,g=1.1*(e.expand*e.expFactor+99),f=b.getElementsByClassName([e.unloadClass,e.loadedClass].join(" ")),setInterval(i,9999),addEventListener("lazybeforeunveil",i),addEventListener("lazybeforeunveil",j._reload,!0)}}if(b.addEventListener){var e,f,g,h=[],i=a.requestAnimationFrame||setTimeout,j={checkElements:function(){var a,b,c,d=-1*g,k=d,l=innerHeight+g,m=innerWidth+g;for(a=0,b=f.length;b>a;a++)c=f[a].getBoundingClientRect(),(c.top>l||c.bottom<d||c.left>m||c.right<k||e.unloadHidden&&!c.top&&!c.bottom&&!c.left&&!c.right)&&h.push(f[a]);i(j.unloadElements)},unload:function(a){var b,d,f,g,h=a.parentNode;if(c.rC(a,e.loadedClass),a.getAttribute(e.srcsetAttr)&&(a.setAttribute("srcset",e.emptySrc),d=!0),h&&"PICTURE"==h.nodeName.toUpperCase()){for(b=h.getElementsByTagName("source"),f=0,g=b.length;g>f;f++)b[f].setAttribute("srcset",e.emptySrc);d=!0}c.hC(a,e.autosizesClass)&&(c.rC(a,e.autosizesClass),a.setAttribute(e.sizesAttr,"auto")),(d||a.getAttribute(e.srcAttr))&&(a.src=e.emptySrc),c.aC(a,e.unloadedClass),c.aC(a,e.lazyClass),c.fire(a,"lazyafterunload")},unloadElements:function(a){for(a=Array.isArray(a)?a:h;a.length;)j.unload(a.shift())},_reload:function(a){c.hC(a.target,e.unloadedClass)&&a.detail&&(a.detail.reloaded=!0,c.rC(a.target,e.unloadedClass))}};addEventListener("lazybeforeunveil",d)}});