forked from aFarkas/lazysizes
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathls.rias.min.js
2 lines (2 loc) · 4.67 KB
/
ls.rias.min.js
1
2
/*! lazysizes - v5.1.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(b,c){var d,e,f,g,h=a.getComputedStyle(b);e=b.parentNode,g={isPicture:!(!e||!n.test(e.nodeName||""))},f=function(a,c){var d=b.getAttribute("data-"+a);if(!d){var e=h.getPropertyValue("--ls-"+a);e&&(d=e.trim())}if(d){if("true"==d)d=!0;else if("false"==d)d=!1;else if(m.test(d))d=parseFloat(d);else if("function"==typeof j[a])d=j[a](b,d);else if(r.test(d))try{d=JSON.parse(d)}catch(a){}g[a]=d}else a in j&&"function"!=typeof j[a]?g[a]=j[a]:c&&"function"==typeof j[a]&&(g[a]=j[a](b,d))};for(d in j)f(d);return c.replace(q,function(a,b){b in g||f(b,!0)}),g}function e(a,b){var c=[],d=function(a,c){return l[typeof b[c]]?b[c]:a};return c.srcset=[],b.absUrl&&(t.setAttribute("href",a),a=t.href),a=((b.prefix||"")+a+(b.postfix||"")).replace(q,d),b.widths.forEach(function(d){var e=b.widthmap[d]||d,f=b.aspectratio||b.ratio,g=!b.aspectratio&&j.traditionalRatio,h={u:a.replace(o,e).replace(p,f?g?Math.round(d*f):Math.round(d/f):""),w:d};c.push(h),c.srcset.push(h.c=h.u+" "+d+"w")}),c}function f(a,c,d){var f=0,g=0,h=d;if(a){if("container"===c.ratio){for(f=h.scrollWidth,g=h.scrollHeight;!(f&&g||h===b);)h=h.parentNode,f=h.scrollWidth,g=h.scrollHeight;f&&g&&(c.ratio=c.traditionalRatio?g/f:f/g)}a=e(a,c),a.isPicture=c.isPicture,v&&"IMG"==d.nodeName.toUpperCase()?d.removeAttribute(i.srcsetAttr):d.setAttribute(i.srcsetAttr,a.srcset.join(", ")),Object.defineProperty(d,"_lazyrias",{value:a,writable:!0})}}function g(a,b){var e=d(a,b);return j.modifyOptions.call(a,{target:a,details:e,detail:e}),c.fire(a,"lazyriasmodifyoptions",e),e}function h(a){return a.getAttribute(a.getAttribute("data-srcattr")||j.srcAttr)||a.getAttribute(i.srcsetAttr)||a.getAttribute(i.srcAttr)||a.getAttribute("data-pfsrcset")||""}var i,j,k=c.cfg,l={string:1,number:1},m=/^\-*\+*\d+\.*\d*$/,n=/^picture$/i,o=/\s*\{\s*width\s*\}\s*/i,p=/\s*\{\s*height\s*\}\s*/i,q=/\s*\{\s*([a-z0-9]+)\s*\}\s*/gi,r=/^\[.*\]|\{.*\}$/,s=/^(?:auto|\d+(px)?)$/,t=b.createElement("a"),u=b.createElement("img"),v="srcset"in u&&!("sizes"in u),w=!!a.HTMLPictureElement&&!v;!function(){var a,b=function(){},d={prefix:"",postfix:"",srcAttr:"data-src",absUrl:!1,modifyOptions:b,widthmap:{},ratio:!1,traditionalRatio:!1,aspectratio:!1};i=c&&c.cfg,i.supportsType||(i.supportsType=function(a){return!a}),i.rias||(i.rias={}),"widths"in(j=i.rias)||(j.widths=[],function(a){for(var b,c=0;!b||b<3e3;)c+=5,c>30&&(c+=1),b=36*c,a.push(b)}(j.widths));for(a in d)a in j||(j[a]=d[a])}(),addEventListener("lazybeforesizes",function(a){if(a.detail.instance==c){var b,d,e,k,l,m,n,p,q,r,t,u,v;if(b=a.target,a.detail.dataAttr&&!a.defaultPrevented&&!j.disabled&&(q=b.getAttribute(i.sizesAttr)||b.getAttribute("sizes"))&&s.test(q)){if(d=h(b),e=g(b,d),t=o.test(e.prefix)||o.test(e.postfix),e.isPicture&&(k=b.parentNode))for(l=k.getElementsByTagName("source"),m=0,n=l.length;m<n;m++)(t||o.test(p=h(l[m])))&&(f(p,e,l[m]),u=!0);t||o.test(d)?(f(d,e,b),u=!0):u&&(v=[],v.srcset=[],v.isPicture=!0,Object.defineProperty(b,"_lazyrias",{value:v,writable:!0})),u&&(w?b.removeAttribute(i.srcAttr):"auto"!=q&&(r={width:parseInt(q,10)},x({target:b,detail:r})))}}},!0);var x=function(){var d=function(a,b){return a.w-b.w},e=function(a){var b,c,d=a.length,e=a[d-1],f=0;for(f;f<d;f++)if(e=a[f],e.d=e.w/a.w,e.d>=a.d){!e.cached&&(b=a[f-1])&&b.d>a.d-.13*Math.pow(a.d,2.2)&&(c=Math.pow(b.d-.6,1.6),b.cached&&(b.d+=.15*c),b.d+(e.d-a.d)*c>a.d&&(e=b));break}return e},f=function(a,b){var d;return!a._lazyrias&&c.pWS&&(d=c.pWS(a.getAttribute(i.srcsetAttr||""))).length&&(Object.defineProperty(a,"_lazyrias",{value:d,writable:!0}),b&&a.parentNode&&(d.isPicture="PICTURE"==a.parentNode.nodeName.toUpperCase())),a._lazyrias},g=function(b){var d=a.devicePixelRatio||1,e=c.getX&&c.getX(b);return Math.min(e||d,2.4,d)},h=function(b,c){var h,i,j,k,l,m;if(l=b._lazyrias,l.isPicture&&a.matchMedia)for(i=0,h=b.parentNode.getElementsByTagName("source"),j=h.length;i<j;i++)if(f(h[i])&&!h[i].getAttribute("type")&&(!(k=h[i].getAttribute("media"))||(matchMedia(k)||{}).matches)){l=h[i]._lazyrias;break}return(!l.w||l.w<c)&&(l.w=c,l.d=g(b),m=e(l.sort(d))),m},j=function(d){if(d.detail.instance==c){var e,g=d.target;if(!v&&(a.respimage||a.picturefill||k.pf))return void b.removeEventListener("lazybeforesizes",j);("_lazyrias"in g||d.detail.dataAttr&&f(g,!0))&&(e=h(g,d.detail.width))&&e.u&&g._lazyrias.cur!=e.u&&(g._lazyrias.cur=e.u,e.cached=!0,c.rAF(function(){g.setAttribute(i.srcAttr,e.u),g.setAttribute("src",e.u)}))}};return w?j=function(){}:addEventListener("lazybeforesizes",j),j}()});