Welcome to mirror list, hosted at ThFree Co, Russian Federation.

lazysizes.min.js « js « static - github.com/Y4er/hugo-theme-easybook.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: e4fce20f135c70b409eb08518878a3002321179c (plain)
1
2
/*! lazysizes - v5.1.1 */
!function(a,b){var c=b(a,a.document);a.lazySizes=c,"object"==typeof module&&module.exports&&(module.exports=c)}("undefined"!=typeof window?window:{},function(a,b){"use strict";var c,d;if(function(){var b,c={lazyClass:"lazyload",loadedClass:"lazyloaded",loadingClass:"lazyloading",preloadClass:"lazypreload",errorClass:"lazyerror",autosizesClass:"lazyautosizes",srcAttr:"data-src",srcsetAttr:"data-srcset",sizesAttr:"data-sizes",minSize:40,customMedia:{},init:!0,expFactor:1.5,hFac:.8,loadMode:2,loadHidden:!0,ricTimeout:0,throttleDelay:125};d=a.lazySizesConfig||a.lazysizesConfig||{};for(b in c)b in d||(d[b]=c[b])}(),!b||!b.getElementsByClassName)return{init:function(){},cfg:d,noSupport:!0};var e=b.documentElement,f=a.Date,g=a.HTMLPictureElement,h="addEventListener",i="getAttribute",j=a[h],k=a.setTimeout,l=a.requestAnimationFrame||k,m=a.requestIdleCallback,n=/^picture$/i,o=/^img|iframe$/i,p=["load","error","lazyincluded","_lazyloaded"],q={},r=Array.prototype.forEach,s=function(a,b){return q[b]||(q[b]=new RegExp("(\\s|^)"+b+"(\\s|$)")),q[b].test(a[i]("class")||"")&&q[b]},t=function(a,b){s(a,b)||a.setAttribute("class",(a[i]("class")||"").trim()+" "+b)},u=function(a,b){var c;(c=s(a,b))&&a.setAttribute("class",(a[i]("class")||"").replace(c," "))},v=function(a,b,c){var d=c?h:"removeEventListener";c&&v(a,b),p.forEach(function(c){a[d](c,b)})},w=function(a,d,e,f,g){var h=b.createEvent("Event");return e||(e={}),e.instance=c,h.initEvent(d,!f,!g),h.detail=e,a.dispatchEvent(h),h},x=function(b,c){var e;!g&&(e=a.picturefill||d.pf)?(c&&c.src&&!b[i]("srcset")&&b.setAttribute("srcset",c.src),e({reevaluate:!0,elements:[b]})):c&&c.src&&(b.src=c.src)},y=function(a,b){return(getComputedStyle(a,null)||{})[b]},z=function(a,b,c){for(c=c||a.offsetWidth;c<d.minSize&&b&&!a._lazysizesWidth;)c=b.offsetWidth,b=b.parentNode;return c},A=function(){var a,c,d=[],e=[],f=d,g=function(){var b=f;for(f=d.length?e:d,a=!0,c=!1;b.length;)b.shift()();a=!1},h=function(d,e){a&&!e?d.apply(this,arguments):(f.push(d),c||(c=!0,(b.hidden?k:l)(g)))};return h._lsFlush=g,h}(),B=function(a,b){return b?function(){A(a)}:function(){var b=this,c=arguments;A(function(){a.apply(b,c)})}},C=function(a){var b,c=0,e=d.throttleDelay,g=d.ricTimeout,h=function(){b=!1,c=f.now(),a()},i=m&&g>49?function(){m(h,{timeout:g}),g!==d.ricTimeout&&(g=d.ricTimeout)}:B(function(){k(h)},!0);return function(a){var d;(a=!0===a)&&(g=33),b||(b=!0,d=e-(f.now()-c),d<0&&(d=0),a||d<9?i():k(i,d))}},D=function(a){var b,c,d=99,e=function(){b=null,a()},g=function(){var a=f.now()-c;a<d?k(g,d-a):(m||e)(e)};return function(){c=f.now(),b||(b=k(g,d))}},E=function(){var g,l,m,p,q,z,E,G,H,I,J,K,L=/^img$/i,M=/^iframe$/i,N="onscroll"in a&&!/(gle|ing)bot/.test(navigator.userAgent),O=0,P=0,Q=0,R=-1,S=function(a){Q--,(!a||Q<0||!a.target)&&(Q=0)},T=function(a){return null==K&&(K="hidden"==y(b.body,"visibility")),K||"hidden"!=y(a.parentNode,"visibility")&&"hidden"!=y(a,"visibility")},U=function(a,c){var d,f=a,g=T(a);for(G-=c,J+=c,H-=c,I+=c;g&&(f=f.offsetParent)&&f!=b.body&&f!=e;)(g=(y(f,"opacity")||1)>0)&&"visible"!=y(f,"overflow")&&(d=f.getBoundingClientRect(),g=I>d.left&&H<d.right&&J>d.top-1&&G<d.bottom+1);return g},V=function(){var a,f,h,j,k,m,n,o,q,r,s,t,u=c.elements;if((p=d.loadMode)&&Q<8&&(a=u.length)){for(f=0,R++;f<a;f++)if(u[f]&&!u[f]._lazyRace)if(!N||c.prematureUnveil&&c.prematureUnveil(u[f]))ba(u[f]);else if((o=u[f][i]("data-expand"))&&(m=1*o)||(m=P),r||(r=!d.expand||d.expand<1?e.clientHeight>500&&e.clientWidth>500?500:370:d.expand,c._defEx=r,s=r*d.expFactor,t=d.hFac,K=null,P<s&&Q<1&&R>2&&p>2&&!b.hidden?(P=s,R=0):P=p>1&&R>1&&Q<6?r:O),q!==m&&(z=innerWidth+m*t,E=innerHeight+m,n=-1*m,q=m),h=u[f].getBoundingClientRect(),(J=h.bottom)>=n&&(G=h.top)<=E&&(I=h.right)>=n*t&&(H=h.left)<=z&&(J||I||H||G)&&(d.loadHidden||T(u[f]))&&(l&&Q<3&&!o&&(p<3||R<4)||U(u[f],m))){if(ba(u[f]),k=!0,Q>9)break}else!k&&l&&!j&&Q<4&&R<4&&p>2&&(g[0]||d.preloadAfterLoad)&&(g[0]||!o&&(J||I||H||G||"auto"!=u[f][i](d.sizesAttr)))&&(j=g[0]||u[f]);j&&!k&&ba(j)}},W=C(V),X=function(a){var b=a.target;if(b._lazyCache)return void delete b._lazyCache;S(a),t(b,d.loadedClass),u(b,d.loadingClass),v(b,Z),w(b,"lazyloaded")},Y=B(X),Z=function(a){Y({target:a.target})},$=function(a,b){try{a.contentWindow.location.replace(b)}catch(c){a.src=b}},_=function(a){var b,c=a[i](d.srcsetAttr);(b=d.customMedia[a[i]("data-media")||a[i]("media")])&&a.setAttribute("media",b),c&&a.setAttribute("srcset",c)},aa=B(function(a,b,c,e,f){var g,h,j,l,p,q;(p=w(a,"lazybeforeunveil",b)).defaultPrevented||(e&&(c?t(a,d.autosizesClass):a.setAttribute("sizes",e)),h=a[i](d.srcsetAttr),g=a[i](d.srcAttr),f&&(j=a.parentNode,l=j&&n.test(j.nodeName||"")),q=b.firesLoad||!!("src"in a&&o.test(a.nodeName)&&(h||g||l)),p={target:a},t(a,d.loadingClass),q&&(clearTimeout(m),m=k(S,2500),v(a,Z,!0)),l&&r.call(j.getElementsByTagName("source"),_),h?a.setAttribute("srcset",h):g&&!l&&(M.test(a.nodeName)?$(a,g):a.src=g),f&&(h||l)&&x(a,{src:g})),a._lazyRace&&delete a._lazyRace,u(a,d.lazyClass),A(function(){var b=a.complete&&a.naturalWidth>1;q&&!b||(b&&t(a,"ls-is-cached"),X(p),a._lazyCache=!0,k(function(){"_lazyCache"in a&&delete a._lazyCache},9)),"lazy"==a.loading&&Q--},!0)}),ba=function(a){if(!a._lazyRace){var b,c=L.test(a.nodeName),e=c&&(a[i](d.sizesAttr)||a[i]("sizes")),f="auto"==e;(!f&&l||!c||!a[i]("src")&&!a.srcset||a.complete||s(a,d.errorClass)||!s(a,d.lazyClass))&&(b=w(a,"lazyunveilread").detail,f&&F.updateElem(a,!0,a.offsetWidth),a._lazyRace=!0,Q++,aa(a,b,f,e,c))}},ca=D(function(){d.loadMode=3,W()}),da=function(){3==d.loadMode&&(d.loadMode=2),ca()},ea=function(){if(!l){if(f.now()-q<999)return void k(ea,999);l=!0,d.loadMode=3,W(),j("scroll",da,!0)}};return{_:function(){q=f.now(),c.elements=b.getElementsByClassName(d.lazyClass),g=b.getElementsByClassName(d.lazyClass+" "+d.preloadClass),j("scroll",W,!0),j("resize",W,!0),a.MutationObserver?new MutationObserver(W).observe(e,{childList:!0,subtree:!0,attributes:!0}):(e[h]("DOMNodeInserted",W,!0),e[h]("DOMAttrModified",W,!0),setInterval(W,999)),j("hashchange",W,!0),["focus","mouseover","click","load","transitionend","animationend"].forEach(function(a){b[h](a,W,!0)}),/d$|^c/.test(b.readyState)?ea():(j("load",ea),b[h]("DOMContentLoaded",W),k(ea,2e4)),c.elements.length?(V(),A._lsFlush()):W()},checkElems:W,unveil:ba,_aLSL:da}}(),F=function(){var a,c=B(function(a,b,c,d){var e,f,g;if(a._lazysizesWidth=d,d+="px",a.setAttribute("sizes",d),n.test(b.nodeName||""))for(e=b.getElementsByTagName("source"),f=0,g=e.length;f<g;f++)e[f].setAttribute("sizes",d);c.detail.dataAttr||x(a,c.detail)}),e=function(a,b,d){var e,f=a.parentNode;f&&(d=z(a,f,d),e=w(a,"lazybeforesizes",{width:d,dataAttr:!!b}),e.defaultPrevented||(d=e.detail.width)&&d!==a._lazysizesWidth&&c(a,f,e,d))},f=function(){var b,c=a.length;if(c)for(b=0;b<c;b++)e(a[b])},g=D(f);return{_:function(){a=b.getElementsByClassName(d.autosizesClass),j("resize",g)},checkElems:g,updateElem:e}}(),G=function(){!G.i&&b.getElementsByClassName&&(G.i=!0,F._(),E._())};return k(function(){d.init&&G()}),c={cfg:d,autoSizer:F,loader:E,init:G,uP:x,aC:t,rC:u,hC:s,fire:w,gW:z,rAF:A}});