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