forked from aFarkas/lazysizes
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ls.respimg.min.js
2 lines (2 loc) · 3.25 KB
/
ls.respimg.min.js
1
2
/*! lazysizes - v1.1.1 - Licensed MIT */
!function(a,b,c){"use strict";var d,e=a.lazySizes&&lazySizes.cfg||a.lazySizesConfig;e||(e={},a.lazySizesConfig=e),e.supportsType||(e.supportsType=function(a){return!a}),a.picturefill||a.respimage||e.pf||(e.pf=function(b){var c,e;if(!a.picturefill&&!a.respimage)for(c=0,e=b.elements.length;e>c;c++)d(b.elements[c])},d=function(){var c=function(a,b,c,d){return Math.abs(b.w-d.w)<Math.abs(a.w-d.w)?b:a},f=function(){var a,b=/(([^,\s].[^\s]+)\s+(\d+)w)/g,c=/\s+\d+h/g,d=/\s/,e=function(b,c,d,e){a.push({c:c,u:d,w:1*e})};return function(f){return a=[],f=f.trim(),f.replace(c,"").replace(b,e),a.length||!f||d.test(f)||a.push({c:f,u:f,w:99}),a}}(),g=function(){g.init||(g.init=!0,addEventListener("resize",function(){var a,c=b.getElementsByClassName("lazymatchmedia"),e=function(){var a,b;for(a=0,b=c.length;b>a;a++)d(c[a])};return function(){clearTimeout(a),a=setTimeout(e,66)}}()))},h=function(b,c){var d,h=b.getAttribute("srcset")||b.getAttribute(e.srcsetAttr);!h&&c&&(h=b._lazypolyfill?b._lazypolyfill._set:b.getAttribute("src")||b.getAttribute(e.srcAttr)),b._lazypolyfill&&b._lazypolyfill._set==h||(d=f(h||""),c&&b.parentNode&&(d.isPicture="PICTURE"==b.parentNode.nodeName.toUpperCase(),d.isPicture&&(lazySizes.aC(b,"lazymatchmedia"),(a.matchMedia||a.Modernizr&&Modernizr.mq)&&g())),d._set=h,Object.defineProperty(b,"_lazypolyfill",{value:d,writable:!0}))},i=function(b){var c=a.devicePixelRatio||1,d=lazySizes.getX&&lazySizes.getX(b),e=Math.min(d||c,2.2,c);return 1.25>e?e*=1.1:e>1.6&&!d&&(e*=.9),e},j=function(b){return a.matchMedia?(j=function(a){return!a||(matchMedia(a)||{}).matches})(b):a.Modernizr&&Modernizr.mq?!b||Modernizr.mq(b):!b},k=function(a){var b,d,f,g,k,l,m;if(g=a,h(g,!0),k=g._lazypolyfill,k.isPicture)for(d=0,b=a.parentNode.getElementsByTagName("source"),f=b.length;f>d;d++)if(e.supportsType(b[d].getAttribute("type"),a)&&j(b[d].getAttribute("media"))){g=b[d],h(g),k=g._lazypolyfill;break}return k.length>1?(m=Math.round(parseInt(g.getAttribute("sizes"),10)*i(a))||lazySizes.getWidth(a,a.parentNode),(!k.w||k.w<m)&&(k.w=m),l=k.reduce(c)):l=k[0],l},l=function(a){var b=k(a);b&&b.u&&a._lazypolyfill.cur!=b.u&&(a._lazypolyfill.cur=b.u,a.setAttribute(e.srcAttr,b.u),a.setAttribute("src",b.u))};return l.parse=f,l}(),a.HTMLPictureElement||e.loadedClass&&e.loadingClass&&!function(){var a=[];['img[sizes$="px"][srcset].',"picture > img:not([srcset])."].forEach(function(b){a.push(b+e.loadedClass),a.push(b+e.loadingClass)}),e.pf({elements:b.querySelectorAll(a.join(", "))})}())}(window,document),function(a){"use strict";var b,c=a.createElement("img");"srcset"in c&&!("sizes"in c)&&(b=/^picture$/i,a.addEventListener("lazybeforeunveil",function(c){var d,e,f,g,h,i,j;!c.defaultPrevented&&!lazySizesConfig.noIOSFix&&(d=c.target)&&(f=d.getAttribute(lazySizesConfig.srcsetAttr))&&(e=d.parentNode)&&((h=b.test(e.nodeName||""))||(g=d.getAttribute("sizes")||d.getAttribute(lazySizesConfig.sizesAttr)))&&(i=h?e:a.createElement("picture"),d._lazyImgSrc||Object.defineProperty(d,"_lazyImgSrc",{value:a.createElement("source"),writable:!0}),j=d._lazyImgSrc,g&&j.setAttribute("sizes",g),j.setAttribute(lazySizesConfig.srcsetAttr,f),d.setAttribute("data-pfsrcset",f),d.removeAttribute(lazySizesConfig.srcsetAttr),h||(e.insertBefore(i,d),i.appendChild(d)),i.insertBefore(j,d))}))}(document);