diff --git a/README.md b/README.md index a89465b0..fee831ee 100644 --- a/README.md +++ b/README.md @@ -179,7 +179,7 @@ Here the list of options: * ``lazySizesConfig.preloadClass`` (default: ``"lazypreload"``): Marker class for elements which should be lazy pre-loaded after onload. Those elements will be even preloaded, if the ``preloadAfterLoad`` option is set to ``false``. Note: This *class* can be also dynamically set (``$currentSlide.next().find('.lazyload').addClass('lazypreload');``). * ``lazySizesConfig.loadingClass`` (default: ``"lazyloading"``): This ``class`` will be added to ``img`` element as soon as image loading starts. Can be used to add unveil effects. * ``lazySizesConfig.loadedClass`` (default: ``"lazyloaded"``): This ``class`` will be added to any element as soon as the image is loaded or the image comes into view. Can be used to add unveil effects or to apply styles. -* ``lazySizesConfig.expand`` (default: ``370``): The ``expand`` option expands the calculated visual viewport area in all directions, so that elements can be loaded before they are becoming visible. (Note: Reasonable values are between ``60`` and ``1000`` (depending on the ``expFactor`` option.) In case you have a lot of small images or you are using the LQIP pattern you can lower the value, in case you have larger images set it to a higher value. Also note, that lazySizes will dynamically shrink this value to ``0``, if the browser is currently downloading and expand it if the browser network is currently idling and the user not scrolling (by multiplying the ``expand`` option with ``2`` (``expFactor``)). This option can be overridden with the ``[data-expand]`` attribute. +* ``lazySizesConfig.expand`` (default: ``360``): The ``expand`` option expands the calculated visual viewport area in all directions, so that elements can be loaded before they are becoming visible. (Note: Reasonable values are between ``60`` and ``1000`` (depending on the ``expFactor`` option.) In case you have a lot of small images or you are using the LQIP pattern you can lower the value, in case you have larger images set it to a higher value. Also note, that lazySizes will dynamically shrink this value to ``0``, if the browser is currently downloading and expand it if the browser network is currently idling and the user not scrolling (by multiplying the ``expand`` option with ``2`` (``expFactor``)). This option can be overridden with the ``[data-expand]`` attribute. ```js window.lazySizesConfig = window.lazySizesConfig || {}; //set expand to a higher value on larger displays diff --git a/bower.json b/bower.json index 0d7119d3..2c737f7f 100644 --- a/bower.json +++ b/bower.json @@ -1,7 +1,7 @@ { "name": "lazysizes", "repo": "afarkas/lazysizes", - "version": "1.1.0-rc3", + "version": "1.1.0", "main": "lazysizes.js", "scripts": [ "lazysizes.js", diff --git a/component.json b/component.json index 02f6bdf7..4e8bfea6 100644 --- a/component.json +++ b/component.json @@ -1,6 +1,6 @@ { "name": "lazysizes", - "version": "1.1.0-rc3", + "version": "1.1.0", "repo": "afarkas/lazysizes", "main": "lazysizes.min.js", "scripts": ["lazysizes.min.js"], diff --git a/lazysizes.js b/lazysizes.js index 9047ce5b..34e16688 100644 --- a/lazysizes.js +++ b/lazysizes.js @@ -502,7 +502,7 @@ customMedia: {}, init: true, expFactor: 2, - expand: 374, + expand: 359, loadMode: 2, throttle: 99 }; diff --git a/lazysizes.min.js b/lazysizes.min.js index 68c78492..c126c8f4 100644 --- a/lazysizes.min.js +++ b/lazysizes.min.js @@ -1,2 +1,2 @@ -/*! lazysizes - v1.1.0-rc3 - Licensed MIT */ -!function(a,b){var c=b(a,a.document);a.lazySizes=c,"object"==typeof module&&module.exports?module.exports=c:"function"==typeof define&&define.amd&&define(c)}(window,function(a,b){"use strict";if(b.getElementsByClassName){var c,d=b.documentElement,e=a.addEventListener,f=a.setTimeout,g=a.requestAnimationFrame||f,h=/^picture$/i,i=["load","error","lazyincluded","_lazyloaded"],j=function(a,b){var c=new RegExp("(\\s|^)"+b+"(\\s|$)");return a.className.match(c)&&c},k=function(a,b){j(a,b)||(a.className+=" "+b)},l=function(a,b){var c;(c=j(a,b))&&(a.className=a.className.replace(c," "))},m=function(a,b,c){var d=c?"addEventListener":"removeEventListener";c&&m(a,b),i.forEach(function(c){a[d](c,b)})},n=function(a,c,d,e,f){var g=b.createEvent("CustomEvent");return g.initCustomEvent(c,!e,!f,d),g.details=g.detail,a.dispatchEvent(g),g},o=function(b,d){var e;a.HTMLPictureElement||((e=a.picturefill||a.respimage||c.pf)?e({reevaluate:!0,reparse:!0,elements:[b]}):d&&d.src&&(b.src=d.src))},p=function(a,b){return getComputedStyle(a,null)[b]},q=function(a,b,d){for(d=d||a.offsetWidth;da&&(a=9),f(i,a)}}},s=function(){var i,q,s,u,v,w,x,y,z,A,B,C,D,E=/^img$/i,F=/^iframe$/i,G="onscroll"in a&&!/glebot/.test(navigator.userAgent),H=0,I=0,J=0,K=0,L=0,M=function(a){K--,a&&a.target&&m(a.target,M),(!a||0>K||!a.target)&&(K=0)},N=function(a,b){var c,d=a,e="hidden"!=p(a,"visibility");for(y-=b,B+=b,z-=b,A+=b;e&&(d=d.offsetParent);)e=(p(d,"opacity")||1)>0,e&&"visible"!=p(d,"overflow")&&(c=d.getBoundingClientRect(),e=A>c.left&&zc.top-1&&yK&&(a=i.length)){for(d=Date.now(),b=L,J++,D>I&&1>K&&J>4&&v>2?(I=D,J=0):I=I!=C&&v>1&&J>3?C:H;a>b;b++,L++)if(i[b]&&!i[b]._lazyRace)if(G)if((k=i[b].getAttribute("data-expand"))&&(h=1*k)||(h=I),l!==h&&(w=innerWidth+h,x=innerHeight+h,j=-1*h,l=h),e=i[b].getBoundingClientRect(),(B=e.bottom)>=j&&(y=e.top)<=x&&(A=e.right)>=j&&(z=e.left)<=w&&(B||A||z||y)&&(s&&3>K&&4>J&&!k&&v>2||N(i[b],h)))S(i[b],!1,e.width),L--,d++,g=!0;else{if(J&&Date.now()-d>3)return L++,void P();!g&&s&&!f&&3>K&&4>J&&v>2&&(q[0]||c.preloadAfterLoad)&&(q[0]||!k&&(B||A||z||y||"auto"!=i[b].getAttribute(c.sizesAttr)))&&(f=q[0]||i[b])}else S(i[b]);f&&!g&&S(f)}L=0},P=r(O),Q=function(a){k(a.target,c.loadedClass),l(a.target,c.loadingClass),m(a.target,Q)},R=function(a,b){try{a.contentWindow.location.replace(b)}catch(c){a.setAttribute("src",b)}},S=function(a,b,d){var e,i,p,q,r,v,w,x,y,z,A,B=a.currentSrc||a.src,C=E.test(a.nodeName),D=a.getAttribute(c.sizesAttr)||a.getAttribute("sizes"),G="auto"==D;(!G&&s||!C||!B||a.complete||j(a,c.errorClass))&&(a._lazyRace=!0,g(function(){if(a._lazyRace&&delete a._lazyRace,l(a,c.lazyClass),!(y=n(a,"lazybeforeunveil",{force:!!b})).defaultPrevented){if(D&&(G?(t.updateElem(a,!0,d),k(a,c.autosizesClass)):a.setAttribute("sizes",D)),v=a.getAttribute(c.srcsetAttr),r=a.getAttribute(c.srcAttr),C&&(w=a.parentNode,x=h.test(w.nodeName||"")),z=y.detail.firesLoad||"src"in a&&(v||r||x),z&&(K++,m(a,M,!0),clearTimeout(u),u=f(M,2500),k(a,c.loadingClass),m(a,Q,!0)),x)for(e=w.getElementsByTagName("source"),i=0,p=e.length;p>i;i++)(A=c.customMedia[e[i].getAttribute("data-media")||e[i].getAttribute("media")])&&e[i].setAttribute("media",A),q=e[i].getAttribute(c.srcsetAttr),q&&e[i].setAttribute("srcset",q);v?a.setAttribute("srcset",v):r&&(F.test(a.nodeName)?R(a,r):a.setAttribute("src",r)),(v||x)&&o(a,{src:r})}(!z||a.complete&&B==(a.currentSrc||a.src))&&(z&&M(y),Q(y)),a=null}))},T=function(){var a,b=function(){c.loadMode=3,P()};s=!0,J+=8,c.loadMode=3,e("scroll",function(){3==c.loadMode&&(c.loadMode=2),clearTimeout(a),a=f(b,99)},!0)};return{_:function(){i=b.getElementsByClassName(c.lazyClass),q=b.getElementsByClassName(c.lazyClass+" "+c.preloadClass),C=c.expand,D=Math.round(C*c.expFactor),e("scroll",P,!0),e("resize",P,!0),a.MutationObserver?new MutationObserver(P).observe(d,{childList:!0,subtree:!0,attributes:!0}):(d.addEventListener("DOMNodeInserted",P,!0),d.addEventListener("DOMAttrModified",P,!0),setInterval(P,999)),e("hashchange",P,!0),["focus","mouseover","click","load","transitionend","animationend","webkitAnimationEnd"].forEach(function(a){b.addEventListener(a,P,!0)}),(s=/d$|^c/.test(b.readyState))?T():(e("load",T),b.addEventListener("DOMContentLoaded",P)),P()},checkElems:P,unveil:S}}(),t=function(){var a,d=function(a,b,c){var d,e,f,g,i=a.parentNode;if(i&&(c=q(a,i,c),g=n(a,"lazybeforesizes",{width:c,dataAttr:!!b}),!g.defaultPrevented&&(c=g.detail.width,c&&c!==a._lazysizesWidth))){if(a._lazysizesWidth=c,c+="px",a.setAttribute("sizes",c),h.test(i.nodeName||""))for(d=i.getElementsByTagName("source"),e=0,f=d.length;f>e;e++)d[e].setAttribute("sizes",c);g.detail.dataAttr||o(a,g.detail)}},f=function(){var b,c=a.length;if(c)for(b=0;c>b;b++)d(a[b])},g=r(f);return{_:function(){a=b.getElementsByClassName(c.autosizesClass),e("resize",g)},checkElems:g,updateElem:d}}(),u=function(){u.i||(u.i=!0,t._(),s._())};return function(){var b,d={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:2,expand:374,loadMode:2,throttle:99};c=a.lazySizesConfig||a.lazysizesConfig||{};for(b in d)b in c||(c[b]=d[b]);a.lazySizesConfig=c,f(function(){c.init&&u()})}(),{cfg:c,autoSizer:t,loader:s,init:u,uP:o,aC:k,rC:l,hC:j,fire:n,gW:q}}}); \ No newline at end of file +/*! lazysizes - v1.1.0 - Licensed MIT */ +!function(a,b){var c=b(a,a.document);a.lazySizes=c,"object"==typeof module&&module.exports?module.exports=c:"function"==typeof define&&define.amd&&define(c)}(window,function(a,b){"use strict";if(b.getElementsByClassName){var c,d=b.documentElement,e=a.addEventListener,f=a.setTimeout,g=a.requestAnimationFrame||f,h=/^picture$/i,i=["load","error","lazyincluded","_lazyloaded"],j=function(a,b){var c=new RegExp("(\\s|^)"+b+"(\\s|$)");return a.className.match(c)&&c},k=function(a,b){j(a,b)||(a.className+=" "+b)},l=function(a,b){var c;(c=j(a,b))&&(a.className=a.className.replace(c," "))},m=function(a,b,c){var d=c?"addEventListener":"removeEventListener";c&&m(a,b),i.forEach(function(c){a[d](c,b)})},n=function(a,c,d,e,f){var g=b.createEvent("CustomEvent");return g.initCustomEvent(c,!e,!f,d),g.details=g.detail,a.dispatchEvent(g),g},o=function(b,d){var e;a.HTMLPictureElement||((e=a.picturefill||a.respimage||c.pf)?e({reevaluate:!0,reparse:!0,elements:[b]}):d&&d.src&&(b.src=d.src))},p=function(a,b){return getComputedStyle(a,null)[b]},q=function(a,b,d){for(d=d||a.offsetWidth;da&&(a=9),f(i,a)}}},s=function(){var i,q,s,u,v,w,x,y,z,A,B,C,D,E=/^img$/i,F=/^iframe$/i,G="onscroll"in a&&!/glebot/.test(navigator.userAgent),H=0,I=0,J=0,K=0,L=0,M=function(a){K--,a&&a.target&&m(a.target,M),(!a||0>K||!a.target)&&(K=0)},N=function(a,b){var c,d=a,e="hidden"!=p(a,"visibility");for(y-=b,B+=b,z-=b,A+=b;e&&(d=d.offsetParent);)e=(p(d,"opacity")||1)>0,e&&"visible"!=p(d,"overflow")&&(c=d.getBoundingClientRect(),e=A>c.left&&zc.top-1&&yK&&(a=i.length)){for(d=Date.now(),b=L,J++,D>I&&1>K&&J>4&&v>2?(I=D,J=0):I=I!=C&&v>1&&J>3?C:H;a>b;b++,L++)if(i[b]&&!i[b]._lazyRace)if(G)if((k=i[b].getAttribute("data-expand"))&&(h=1*k)||(h=I),l!==h&&(w=innerWidth+h,x=innerHeight+h,j=-1*h,l=h),e=i[b].getBoundingClientRect(),(B=e.bottom)>=j&&(y=e.top)<=x&&(A=e.right)>=j&&(z=e.left)<=w&&(B||A||z||y)&&(s&&3>K&&4>J&&!k&&v>2||N(i[b],h)))S(i[b],!1,e.width),L--,d++,g=!0;else{if(J&&Date.now()-d>3)return L++,void P();!g&&s&&!f&&3>K&&4>J&&v>2&&(q[0]||c.preloadAfterLoad)&&(q[0]||!k&&(B||A||z||y||"auto"!=i[b].getAttribute(c.sizesAttr)))&&(f=q[0]||i[b])}else S(i[b]);f&&!g&&S(f)}L=0},P=r(O),Q=function(a){k(a.target,c.loadedClass),l(a.target,c.loadingClass),m(a.target,Q)},R=function(a,b){try{a.contentWindow.location.replace(b)}catch(c){a.setAttribute("src",b)}},S=function(a,b,d){var e,i,p,q,r,v,w,x,y,z,A,B=a.currentSrc||a.src,C=E.test(a.nodeName),D=a.getAttribute(c.sizesAttr)||a.getAttribute("sizes"),G="auto"==D;(!G&&s||!C||!B||a.complete||j(a,c.errorClass))&&(a._lazyRace=!0,g(function(){if(a._lazyRace&&delete a._lazyRace,l(a,c.lazyClass),!(y=n(a,"lazybeforeunveil",{force:!!b})).defaultPrevented){if(D&&(G?(t.updateElem(a,!0,d),k(a,c.autosizesClass)):a.setAttribute("sizes",D)),v=a.getAttribute(c.srcsetAttr),r=a.getAttribute(c.srcAttr),C&&(w=a.parentNode,x=h.test(w.nodeName||"")),z=y.detail.firesLoad||"src"in a&&(v||r||x),z&&(K++,m(a,M,!0),clearTimeout(u),u=f(M,2500),k(a,c.loadingClass),m(a,Q,!0)),x)for(e=w.getElementsByTagName("source"),i=0,p=e.length;p>i;i++)(A=c.customMedia[e[i].getAttribute("data-media")||e[i].getAttribute("media")])&&e[i].setAttribute("media",A),q=e[i].getAttribute(c.srcsetAttr),q&&e[i].setAttribute("srcset",q);v?a.setAttribute("srcset",v):r&&(F.test(a.nodeName)?R(a,r):a.setAttribute("src",r)),(v||x)&&o(a,{src:r})}(!z||a.complete&&B==(a.currentSrc||a.src))&&(z&&M(y),Q(y)),a=null}))},T=function(){var a,b=function(){c.loadMode=3,P()};s=!0,J+=8,c.loadMode=3,e("scroll",function(){3==c.loadMode&&(c.loadMode=2),clearTimeout(a),a=f(b,99)},!0)};return{_:function(){i=b.getElementsByClassName(c.lazyClass),q=b.getElementsByClassName(c.lazyClass+" "+c.preloadClass),C=c.expand,D=Math.round(C*c.expFactor),e("scroll",P,!0),e("resize",P,!0),a.MutationObserver?new MutationObserver(P).observe(d,{childList:!0,subtree:!0,attributes:!0}):(d.addEventListener("DOMNodeInserted",P,!0),d.addEventListener("DOMAttrModified",P,!0),setInterval(P,999)),e("hashchange",P,!0),["focus","mouseover","click","load","transitionend","animationend","webkitAnimationEnd"].forEach(function(a){b.addEventListener(a,P,!0)}),(s=/d$|^c/.test(b.readyState))?T():(e("load",T),b.addEventListener("DOMContentLoaded",P)),P()},checkElems:P,unveil:S}}(),t=function(){var a,d=function(a,b,c){var d,e,f,g,i=a.parentNode;if(i&&(c=q(a,i,c),g=n(a,"lazybeforesizes",{width:c,dataAttr:!!b}),!g.defaultPrevented&&(c=g.detail.width,c&&c!==a._lazysizesWidth))){if(a._lazysizesWidth=c,c+="px",a.setAttribute("sizes",c),h.test(i.nodeName||""))for(d=i.getElementsByTagName("source"),e=0,f=d.length;f>e;e++)d[e].setAttribute("sizes",c);g.detail.dataAttr||o(a,g.detail)}},f=function(){var b,c=a.length;if(c)for(b=0;c>b;b++)d(a[b])},g=r(f);return{_:function(){a=b.getElementsByClassName(c.autosizesClass),e("resize",g)},checkElems:g,updateElem:d}}(),u=function(){u.i||(u.i=!0,t._(),s._())};return function(){var b,d={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:2,expand:359,loadMode:2,throttle:99};c=a.lazySizesConfig||a.lazysizesConfig||{};for(b in d)b in c||(c[b]=d[b]);a.lazySizesConfig=c,f(function(){c.init&&u()})}(),{cfg:c,autoSizer:t,loader:s,init:u,uP:o,aC:k,rC:l,hC:j,fire:n,gW:q}}}); \ No newline at end of file diff --git a/package.json b/package.json index 6c41a86a..0e0ae687 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "lazysizes", - "version": "1.1.0-rc3", + "version": "1.1.0", "filename": "lazysizes.min.js", "author": "Alexander Farkas ", "repository": { diff --git a/plugins/aspectratio/ls.aspectratio.min.js b/plugins/aspectratio/ls.aspectratio.min.js index 48e03261..40aaca87 100644 --- a/plugins/aspectratio/ls.aspectratio.min.js +++ b/plugins/aspectratio/ls.aspectratio.min.js @@ -1,2 +1,2 @@ -/*! lazysizes - v1.1.0-rc3 - Licensed MIT */ +/*! lazysizes - v1.1.0 - Licensed MIT */ !function(a,b){"use strict";function c(){this.ratioElems=b.getElementsByClassName("lazyaspectratio"),this._setupEvents(),this.processImages()}if(a.addEventListener){var d,e,f,g=/^picture$/i,h="data-aspectratio",i="img["+h+"]",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(b,c){f?f(b).addClass(c):a.lazySizes?lazySizes.aC(b,c):b.classList.add(c)},l=function(b,c){f?f(b).removeClass(c):a.lazySizes?lazySizes.rC(b,c):b.classList.remove(c)};c.prototype={_setupEvents:function(){var a=this,c=function(b){b.naturalWidth<36?a.addAspectRatio(b,!0):a.removeAspectRatio(b,!0)},d=function(){a.processImages()};b.addEventListener("load",function(a){a.target.getAttribute&&a.target.getAttribute(h)&&c(a.target)},!0),addEventListener("resize",function(){var b,d=function(){var b,d;for(b=0,d=a.ratioElems.length;d>b;b++)c(a.ratioElems[b])};return function(){clearTimeout(b),b=setTimeout(d,33)}}()),b.addEventListener("DOMContentLoaded",d),addEventListener("load",d)},processImages:function(a){var c,d;a||(a=b),c="length"in a&&!a.nodeName?a:a.querySelectorAll(i);for(d=0;d36?this.removeAspectRatio(c[d]):this.addAspectRatio(c[d])},getSelectedRatio:function(b){var c,d,e,f,i,k=b.parentNode;if(k&&g.test(k.nodeName||""))for(e=k.getElementsByTagName("source"),c=0,d=e.length;d>c;c++)if(f=e[c].getAttribute("data-media")||e[c].getAttribute("media"),a.lazySizesConfig&&lazySizesConfig.customMedia[f]&&(f=lazySizesConfig.customMedia[f]),j(f)){i=e[c].getAttribute(h);break}return i||b.getAttribute(h)||""},parseRatio:function(){var a=/^\s*([+\d\.]+)(\s*[\/x]\s*([+\d\.]+))?\s*$/,b={};return function(c){return!b[c]&&c.match(a)&&(b[c]=RegExp.$3?RegExp.$1/RegExp.$3:1*RegExp.$1),b[c]}}(),addAspectRatio:function(b,c){var d,e=b.offsetWidth;return c||k(b,"lazyaspectratio"),36>e?void(e&&a.console&&console.log("Define width of image, so we can calculate the height")):(d=this.getSelectedRatio(b),d=this.parseRatio(d),void(d&&(b.style.height=e/d+"px")))},removeAspectRatio:function(a){l(a,"lazyaspectratio"),a.style.height="",a.removeAttribute(h)}},e=function(){f=a.jQuery||a.Zepto||a.shoestring||a.$,f&&f.fn&&!f.fn.imageRatio&&f.fn.filter&&f.fn.add&&f.fn.find?f.fn.imageRatio=function(){return d.processImages(this.find(i).add(this.filter(i))),this}:f=!1},e(),setTimeout(e),d=new c,a.imageRatio=d,"object"==typeof module&&module.exports?module.exports=d:"function"==typeof define&&define.amd&&define(d)}}(window,document); \ No newline at end of file diff --git a/plugins/bgset/ls.bgset.min.js b/plugins/bgset/ls.bgset.min.js index 2b7e3d5e..be81f7fc 100644 --- a/plugins/bgset/ls.bgset.min.js +++ b/plugins/bgset/ls.bgset.min.js @@ -1,2 +1,2 @@ -/*! lazysizes - v1.1.0-rc3 - Licensed MIT */ +/*! lazysizes - v1.1.0 - Licensed MIT */ !function(){"use strict";if(window.addEventListener){var a=/\s*\|\s+|\s+\|\s*/g,b=/^(.+?)(?:\s+\[\s*(.+?)\s*\])?$/,c=function(a){var b=lazySizes.gW(a,a.parentNode);return(!a._lazysizesWidth||b>a._lazysizesWidth)&&(a._lazysizesWidth=b),a._lazysizesWidth},d=function(c,d,e){var f=document.createElement("picture"),g=d.getAttribute(lazySizesConfig.sizesAttr),h=d.getAttribute("data-optimumx");d._lazybgset&&d._lazybgset.parentNode==d&&d.removeChild(d._lazybgset),Object.defineProperty(e,"_lazybgset",{value:d,writable:!0}),Object.defineProperty(d,"_lazybgset",{value:f,writable:!0}),c=c.split(a),f.style.display="none",e.className=lazySizesConfig.lazyClass,1!=c.length||g||(g="auto"),c.forEach(function(a){var c=document.createElement("source");g&&"auto"!=g&&c.setAttribute("sizes",g),a.match(b)&&(c.setAttribute(lazySizesConfig.srcsetAttr,RegExp.$1),RegExp.$2&&c.setAttribute("media",RegExp.$2)),f.appendChild(c)}),g&&(e.setAttribute(lazySizesConfig.sizesAttr,g),d.removeAttribute(lazySizesConfig.sizesAttr)),h&&e.setAttribute("data-optimumx",h),f.appendChild(e),d.appendChild(f)};addEventListener("lazybeforeunveil",function(a){var b,c,e;!a.defaultPrevented&&(b=a.target.getAttribute("data-bgset"))&&(e=a.target,c=document.createElement("img"),c._lazybgsetLoading=!0,a.detail.firesLoad=!0,d(b,e,c),lazySizes.loader.unveil(c),lazySizes.fire(c,"_lazyloaded",{},!0,!0))}),document.addEventListener("load",function(a){if(a.target._lazybgset){var b=a.target,c=b._lazybgset,d=b.currentSrc||b.src;d&&(c.style.backgroundImage="url("+d+")"),b._lazybgsetLoading&&(lazySizes.fire(c,"_lazyloaded",{},!1,!0),delete b._lazybgsetLoading)}},!0),addEventListener("lazybeforesizes",function(a){!a.defaultPrevented&&a.target._lazybgset&&(a.detail.width=c(a.target._lazybgset))})}}(); \ No newline at end of file diff --git a/plugins/custommedia/ls.custommedia.min.js b/plugins/custommedia/ls.custommedia.min.js index b0870b2c..e87c322a 100644 --- a/plugins/custommedia/ls.custommedia.min.js +++ b/plugins/custommedia/ls.custommedia.min.js @@ -1,2 +1,2 @@ -/*! lazysizes - v1.1.0-rc3 - Licensed MIT */ +/*! lazysizes - v1.1.0 - Licensed MIT */ !function(a){"use strict";var b=document.documentElement,c=function(){if(a.lazySizes&&!a.lazySizes.getCustomMedias){var d=a.lazySizes;d.getCustomMedias=function(){var a=/['"]/g,b=/\s*\|\s*/g,c=/^([a-z0-9_-]+)\s*:\s*(.+)$/i,e=function(b,c){return(getComputedStyle(b,c).getPropertyValue("content")||"none").replace(a,"").trim()},f=function(a,d){a.split(b).forEach(function(a){a.match(c)&&(d[RegExp.$1]=RegExp.$2)})};return function(a,b){return a=a||d.cfg.customMedia,b=b||document.querySelector("html"),f(e(b,":before"),a),f(e(b,":after"),a),a}}(),d.updateCustomMedia=function(){var c,e,f,g=b.querySelectorAll("source[media][data-media][srcset]");for(d.getCustomMedias(),c=0,e=g.length;e>c;c++)(f=d.cfg.customMedia[g[c].getAttribute("data-media")||g[c].getAttribute("media")])&&g[c].setAttribute("media",f);if(!a.HTMLPictureElement)for(g=b.querySelector("source[media][data-media][srcset] ~ img"),c=0,e=g.length;e>c;c++)d.uP(g[c]);d.autoSizer.checkElems()},d.getCustomMedias(),b.removeEventListener("lazybeforeunveil",c)}};a.addEventListener&&(b.addEventListener("lazybeforeunveil",c),c(),setTimeout(c))}(window); \ No newline at end of file diff --git a/plugins/fix-ios-sizes/fix-ios-sizes.min.js b/plugins/fix-ios-sizes/fix-ios-sizes.min.js index 68dca5c3..60570b73 100644 --- a/plugins/fix-ios-sizes/fix-ios-sizes.min.js +++ b/plugins/fix-ios-sizes/fix-ios-sizes.min.js @@ -1,2 +1,2 @@ -/*! lazysizes - v1.1.0-rc3 - Licensed MIT */ +/*! lazysizes - v1.1.0 - Licensed MIT */ !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); \ No newline at end of file diff --git a/plugins/include/ls.include.min.js b/plugins/include/ls.include.min.js index 6130449c..77fd43f6 100644 --- a/plugins/include/ls.include.min.js +++ b/plugins/include/ls.include.min.js @@ -1,2 +1,2 @@ -/*! lazysizes - v1.1.0-rc3 - Licensed MIT */ +/*! lazysizes - v1.1.0 - Licensed MIT */ !function(a,b){"use strict";function c(a){a.match(z)?this.urls[RegExp.$1]=t.map[RegExp.$2]||RegExp.$2:this.urls.include=t.map[a]||a}function d(a){var b,d,e;return a=a.trim(),a=t.map[a]||a,d=a.match(A),d?(e=RegExp.$1,b={condition:s.include.conditions[RegExp.$3]||s.customMedia[RegExp.$3]||RegExp.$2||null,name:RegExp.$3}):(e=a,b={condition:null,name:""}),b.urls={},(t.map[e]||e).split(y).forEach(c,b),!b.urls.include&&b.urls.amd&&(this.saved=!0,b.initial=this),b}function e(a){var b,c,e=a.getAttribute("data-include")||"",f=a.lazyInclude;return f&&f.str==e||(c={saved:!1,content:null},f={str:e,candidates:(t.map[e]||e).split(w).map(d,c)},!(b=f.candidates.length)||f.candidates[b-1].condition?(c.saved=!0,f.candidates.push({urls:{},condition:null,name:"initial",content:c})):c.saved&&1==f.candidates.length&&(c.saved=!1),f.initialContent=c,c.saved&&(c.content=a.innerHTML),a.lazyInclude=f,f.candidates.length>1?lazySizes.aC(a,"lazyconditionalinclude"):lazySizes.rC(a,"lazyconditionalinclude")),f}function f(b,c){var d=!c.condition;return c.condition&&(g(),v[c.name]?d=!0:a.matchMedia&&"string"==typeof c.condition?d=(matchMedia(c.condition)||{}).matches:"function"==typeof c.condition&&(d=c.condition(b,c))),d}function g(){var a;v||(u||(u=b.querySelector(t.contentElement)),u?(a=(getComputedStyle(u,":after").getPropertyValue("content")||"none").replace(B,""),v={},a&&(v[a]=1),a=(getComputedStyle(u,":before").getPropertyValue("content")||"none").replace(B,""),a&&(v[a]=1)):v={})}function h(a){var b,c,d=a.lazyInclude;if(d&&d.candidates)for(b=0;b=200&&300>h||304===h:!0,oldCandidate:g,insert:!0,resetHTML:j},l={target:b,details:k,detail:k};c.modules=f,g&&g.modules&&(g.modules.forEach(n,l),g.modules=null,k.resetHTML&&null==k.content&&c.initial&&c.initial.saved&&(k.content=c.initial.content)),f.forEach(m,l),d=lazySizes.fire(b,"lazyincludeloaded",k),k.insert&&k.isSuccess&&!d.defaultPrevented&&null!=k.content&&k.content!=b.innerHTML&&(a.jQuery?jQuery(b).html(k.content):b.innerHTML=k.content),E.d(),f.forEach(o,l),setTimeout(function(){lazySizes.fire(b,"lazyincluded",k)}),e=null,f=null},b.lazyInclude.current=c,b.setAttribute("data-currentinclude",c.name),c.urls.css&&l(c.urls.css),null==h.content&&c.urls.include?i(h,function(a){e=a,f&&d()}):e=h,c.urls.amd?j(c.urls.amd,function(a){f=a,e&&d()}):f=[],void(e&&f&&d()))}function q(a){var b,c=e(a);return c.candidates.length&&C.contains(a)?(b=h(a),b&&p(a,b),!0):void 0}function r(a){!a.defaultPrevented&&a.target.getAttribute("data-include")&&(E.q(a.target),a.detail.firesLoad=!0)}if(b.getElementsByClassName){var s,t,u,v,w=/\s*,+\s+/,x={},y=/\s+/,z=/^(amd|css)\:(.+)/i,A=/(.+)\s+(\(\s*(.+)\s*\))/,B=/['"]/g,C=b.documentElement,D=b.getElementsByClassName("lazyconditionalinclude"),E=function(){var a=2,b=3,c=a,d=0,e=0,f=[],g=function(){var a,b=function(){f.length&&(d=0,f.d())};return function(){clearTimeout(a),a=setTimeout(b,999)}}();return{q:function(a){var h=null==a.getAttribute("data-lazyqueue");h&&(e++,c=b),d>c?f[h?"unshift":"push"](a):q(a)&&(d++,g())},d:function(){if(d&&d--,e>0&&(e--,e||(c=a)),!(d>c)){for(;f.length;)if(q(f.shift())){d++;break}g()}}}}(),F=function(){var a,b=function(){for(var a=0,b=D.length;b>a;a++)!lazySizes.hC(D[a],s.lazyClass)&&h(D[a])&&lazySizes.aC(D[a],s.lazyClass)};return function(c){clearTimeout(a),v=null,a=setTimeout(b,"resize"==c.type?31:0)}}();s=a.lazySizes&&lazySizes.cfg||a.lazySizesConfig,s||(s={},a.lazySizesConfig=s),s.include||(s.include={}),t=s.include,t.contentElement||(t.contentElement="html"),t.conditions||(t.conditions={}),t.map||(t.map={}),"preloadAfterLoad"in s||(s.preloadAfterLoad=!0),addEventListener("lazybeforeunveil",r,!1),addEventListener("resize",F,!1),addEventListener("lazyrefreshincludes",F,!1)}}(window,document); \ No newline at end of file diff --git a/plugins/noscript/ls.noscript.min.js b/plugins/noscript/ls.noscript.min.js index 2e9b1f0d..e11cc386 100644 --- a/plugins/noscript/ls.noscript.min.js +++ b/plugins/noscript/ls.noscript.min.js @@ -1,2 +1,2 @@ -/*! lazysizes - v1.1.0-rc3 - Licensed MIT */ +/*! lazysizes - v1.1.0 - Licensed MIT */ !function(){"use strict";if(window.addEventListener){var a={nodeName:""},b=!!window.HTMLPictureElement,c=function(c){var d,e,f,g,h,i=c.target.querySelectorAll("img, iframe");for(d=0;dh)||f||(f=!0,c.detail.firesLoad=!1,lazySizes.fire(c.target,"_lazyloaded",{},!1,!0)),a&&a.target&&(a.target.removeEventListener("load",g),a.target.removeEventListener("error",g))},setTimeout(g,3500)),h++,i[d].addEventListener("load",g),i[d].addEventListener("error",g))};addEventListener("lazybeforeunveil",function(a){if(!a.defaultPrevented&&null!=a.target.getAttribute("data-noscript")){var b=a.target.querySelector('noscript, script[type*="html"]')||{},d=b.textContent||b.innerText;d&&(a.target.innerHTML=d,c(a))}})}}(); \ No newline at end of file diff --git a/plugins/optimumx/README.md b/plugins/optimumx/README.md index 1b74f916..ea0ecf4b 100644 --- a/plugins/optimumx/README.md +++ b/plugins/optimumx/README.md @@ -104,16 +104,14 @@ The predefined (ugly) ``getOptimumX`` callback looks like this: ```js window.lazySizesConfig = window.lazySizesConfig || {}; -window.lazySizesConfig.getOptimumX = function(/*element*/){ +window.lazySizesConfig.config.getOptimumX = function(/*element*/){ var dpr = window.devicePixelRatio || 1; if(dpr > 2.4){ - dpr *= 0.63; // returns 1.9 for 3 + dpr *= 0.7; // returns 2.1 for 3 } else if(dpr > 1.9){ dpr *= 0.8; // returns 1.6 for 2 - } else if(dpr > 1.4){ - dpr *= 0.9; // returns 1.35 for 1.5 } - return Math.round(dpr * 100) / 100; + return Math.min(Math.round(dpr * 100) / 100, 2); }; ``` diff --git a/plugins/optimumx/ls.optimumx.js b/plugins/optimumx/ls.optimumx.js index 2b138d67..5b35da69 100644 --- a/plugins/optimumx/ls.optimumx.js +++ b/plugins/optimumx/ls.optimumx.js @@ -199,11 +199,9 @@ config.getOptimumX = function(/*element*/){ var dpr = window.devicePixelRatio || 1; if(dpr > 2.4){ - dpr *= 0.63; // returns 1.9 for 3 + dpr *= 0.7; // returns 2.1 for 3 } else if(dpr > 1.9){ dpr *= 0.8; // returns 1.6 for 2 - } else if(dpr > 1.4){ - dpr *= 0.9; // returns 1.35 for 1.5 } return Math.min(Math.round(dpr * 100) / 100, 2); }; diff --git a/plugins/optimumx/ls.optimumx.min.js b/plugins/optimumx/ls.optimumx.min.js index 328af8cc..fb38eeea 100644 --- a/plugins/optimumx/ls.optimumx.min.js +++ b/plugins/optimumx/ls.optimumx.min.js @@ -1,2 +1,2 @@ -/*! lazysizes - v1.1.0-rc3 - Licensed MIT */ -!function(a,b){"use strict";if(a.addEventListener){var c,d=/^picture$/i,e=b.documentElement,f=function(){var a,b=/(([^,\s].[^\s]+)\s+(\d+)w)/g,c=/\s+\d+h/g,d=function(b,c,d,e){a.push({c:c,u:d,w:1*e})};return function(e){return a=[],e.replace(c,"").replace(b,d),a}}(),g=function(){var a=function(a,b){return a.w-b.w},b=function(b,c){var d={srcset:b.getAttribute(lazySizes.cfg.srcsetAttr)||""},e=f(d.srcset);return Object.defineProperty(b,c,{value:d,writable:!0}),d.cands=e,d.index=0,d.dirty=!1,e[0]&&e[0].w?(e.sort(a),d.cSrcset=[e[d.index].c]):(d.cSrcset=d.srcset?[d.srcset]:[],d.cands=[]),d};return function(a,c){var e,f,g,h;if(!a[c]&&(h=a.parentNode||{},a[c]=b(a,c),a[c].isImg=!0,d.test(h.nodeName||"")))for(a[c].picture=!0,e=h.getElementsByTagName("source"),f=0,g=e.length;g>f;f++)b(e[f],c).isImg=!1;return a[c]}}(),h={_lazyOptimumx:function(){var a=function(a,b,c){var d,e;return a&&a.w?a.w>c?!1:(d=1-a.w/c,e=b/c-1,0>e-d):!0};return function(b,c){var d,e;for(d=b.index+1;di;i++)a(f[i],c,d,e);a(b,c,d,e)}}(),j=function(a){var b=a.getAttribute("data-optimumx")||a.getAttribute("data-maxdpr");return b&&(b="auto"==b?c.getOptimumX(a):parseFloat(b,10)),b},k=function(){a.lazySizes&&!a.lazySizes.getOptimumX&&(lazySizes.getX=j,lazySizes.pWS=f,e.removeEventListener("lazybeforeunveil",k))};e.addEventListener("lazybeforeunveil",k),setTimeout(k),c=a.lazySizes&&lazySizes.cfg||a.lazySizesConfig,c||(c={},a.lazySizesConfig=c),"function"!=typeof c.getOptimumX&&(c.getOptimumX=function(){var b=a.devicePixelRatio||1;return b>2.4?b*=.63:b>1.9?b*=.8:b>1.4&&(b*=.9),Math.min(Math.round(100*b)/100,2)}),a.devicePixelRatio&&(addEventListener("lazybeforesizes",function(a){var b,c,d,e;a.defaultPrevented||!(b=j(a.target))||b>=devicePixelRatio||(c=g(a.target,"_lazyOptimumx"),d=a.detail.width*b,d&&(c.width||0)f;f++)b(e[f],c).isImg=!1;return a[c]}}(),h={_lazyOptimumx:function(){var a=function(a,b,c){var d,e;return a&&a.w?a.w>c?!1:(d=1-a.w/c,e=b/c-1,0>e-d):!0};return function(b,c){var d,e;for(d=b.index+1;di;i++)a(f[i],c,d,e);a(b,c,d,e)}}(),j=function(a){var b=a.getAttribute("data-optimumx")||a.getAttribute("data-maxdpr");return b&&(b="auto"==b?c.getOptimumX(a):parseFloat(b,10)),b},k=function(){a.lazySizes&&!a.lazySizes.getOptimumX&&(lazySizes.getX=j,lazySizes.pWS=f,e.removeEventListener("lazybeforeunveil",k))};e.addEventListener("lazybeforeunveil",k),setTimeout(k),c=a.lazySizes&&lazySizes.cfg||a.lazySizesConfig,c||(c={},a.lazySizesConfig=c),"function"!=typeof c.getOptimumX&&(c.getOptimumX=function(){var b=a.devicePixelRatio||1;return b>2.4?b*=.7:b>1.9&&(b*=.8),Math.min(Math.round(100*b)/100,2)}),a.devicePixelRatio&&(addEventListener("lazybeforesizes",function(a){var b,c,d,e;a.defaultPrevented||!(b=j(a.target))||b>=devicePixelRatio||(c=g(a.target,"_lazyOptimumx"),d=a.detail.width*b,d&&(c.width||0)b;b++)lazySizes.loader.unveil(c[b])},addEventListener("beforeprint",d,!1),!("onbeforeprint"in a)&&a.matchMedia&&(e=matchMedia("print"))&&e.addListener&&e.addListener(function(){e.matches&&d()}))}(window); \ No newline at end of file diff --git a/plugins/progressive/ls.progressive.min.js b/plugins/progressive/ls.progressive.min.js index d7890f78..7fd20fc4 100644 --- a/plugins/progressive/ls.progressive.min.js +++ b/plugins/progressive/ls.progressive.min.js @@ -1,2 +1,2 @@ -/*! lazysizes - v1.1.0-rc3 - Licensed MIT */ +/*! lazysizes - v1.1.0 - Licensed MIT */ !function(a){"use strict";var b,c;"srcset"in a.createElement("img")&&(b=/^img$/i,c=function(a){a.target.style.backgroundSize="",a.target.style.backgroundImage="",a.target.removeEventListener(a.type,c)},a.addEventListener("lazybeforeunveil",function(a){var d=a.target;if(b.test(d.nodeName)){var e=d.getAttribute("src");e&&(d.style.backgroundSize="100% 100%",d.style.backgroundImage="url("+e+")",d.removeAttribute("src"),d.addEventListener("load",c))}},!1))}(document); \ No newline at end of file diff --git a/plugins/respimg/ls.respimg.js b/plugins/respimg/ls.respimg.js index ec9c8307..37a07b3e 100644 --- a/plugins/respimg/ls.respimg.js +++ b/plugins/respimg/ls.respimg.js @@ -123,10 +123,10 @@ var optimum = lazySizes.getX && lazySizes.getX(elem); var x = Math.min(optimum || dpr, 2.2, dpr); - if(x < 1.2){ - x *= 1.05; + if(x < 1.25){ + x *= 1.1; } else if(x > 1.6 && !optimum){ - x *= 0.95; + x *= 0.9; } return x; diff --git a/plugins/respimg/ls.respimg.min.js b/plugins/respimg/ls.respimg.min.js index ffd48213..1cd142f1 100644 --- a/plugins/respimg/ls.respimg.min.js +++ b/plugins/respimg/ls.respimg.min.js @@ -1,2 +1,2 @@ -/*! lazysizes - v1.1.0-rc3 - Licensed MIT */ -!function(a,b){"use strict";var c,d=a.lazySizes&&lazySizes.cfg||a.lazySizesConfig;d||(d={},a.lazySizesConfig=d),d.supportsType||(d.supportsType=function(a){return!a}),a.picturefill||a.respimage||d.pf||(d.pf=function(b){var d,e;if(!a.picturefill&&!a.respimage)for(d=0,e=b.elements.length;e>d;d++)c(b.elements[d])},c=function(){var e=function(a,b,c,d){return Math.abs(b.w-d.w)a;a++)c(d[a])};return function(){clearTimeout(a),a=setTimeout(e,66)}}()))},h=function(b,c){var e,h=b.getAttribute("srcset")||b.getAttribute(d.srcsetAttr);!h&&c&&(h=b._lazypolyfill?b._lazypolyfill._set:b.getAttribute("src")||b.getAttribute(d.srcAttr)),b._lazypolyfill&&b._lazypolyfill._set==h||(e=f(h||""),c&&b.parentNode&&(e.isPicture="PICTURE"==b.parentNode.nodeName.toUpperCase(),e.isPicture&&(lazySizes.aC(b,"lazymatchmedia"),(a.matchMedia||a.Modernizr&&Modernizr.mq)&&g())),e._set=h,Object.defineProperty(b,"_lazypolyfill",{value:e,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.2>e?e*=1.05:e>1.6&&!d&&(e*=.95),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,c,f,g,k,l,m;if(g=a,h(g,!0),k=g._lazypolyfill,k.isPicture)for(c=0,b=a.parentNode.getElementsByTagName("source"),f=b.length;f>c;c++)if(d.supportsType(b[c].getAttribute("type"),a)&&j(b[c].getAttribute("media"))){g=b[c],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 img:not([srcset])."].forEach(function(b){a.push(b+d.loadedClass),a.push(b+d.loadingClass)}),d.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); \ No newline at end of file +/*! lazysizes - v1.1.0 - Licensed MIT */ +!function(a,b){"use strict";var c,d=a.lazySizes&&lazySizes.cfg||a.lazySizesConfig;d||(d={},a.lazySizesConfig=d),d.supportsType||(d.supportsType=function(a){return!a}),a.picturefill||a.respimage||d.pf||(d.pf=function(b){var d,e;if(!a.picturefill&&!a.respimage)for(d=0,e=b.elements.length;e>d;d++)c(b.elements[d])},c=function(){var e=function(a,b,c,d){return Math.abs(b.w-d.w)a;a++)c(d[a])};return function(){clearTimeout(a),a=setTimeout(e,66)}}()))},h=function(b,c){var e,h=b.getAttribute("srcset")||b.getAttribute(d.srcsetAttr);!h&&c&&(h=b._lazypolyfill?b._lazypolyfill._set:b.getAttribute("src")||b.getAttribute(d.srcAttr)),b._lazypolyfill&&b._lazypolyfill._set==h||(e=f(h||""),c&&b.parentNode&&(e.isPicture="PICTURE"==b.parentNode.nodeName.toUpperCase(),e.isPicture&&(lazySizes.aC(b,"lazymatchmedia"),(a.matchMedia||a.Modernizr&&Modernizr.mq)&&g())),e._set=h,Object.defineProperty(b,"_lazypolyfill",{value:e,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,c,f,g,k,l,m;if(g=a,h(g,!0),k=g._lazypolyfill,k.isPicture)for(c=0,b=a.parentNode.getElementsByTagName("source"),f=b.length;f>c;c++)if(d.supportsType(b[c].getAttribute("type"),a)&&j(b[c].getAttribute("media"))){g=b[c],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 img:not([srcset])."].forEach(function(b){a.push(b+d.loadedClass),a.push(b+d.loadingClass)}),d.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); \ No newline at end of file diff --git a/plugins/rias/ls.rias.js b/plugins/rias/ls.rias.js index fed49698..e3a7c0cb 100644 --- a/plugins/rias/ls.rias.js +++ b/plugins/rias/ls.rias.js @@ -226,10 +226,10 @@ var optimum = lazySizes.getX && lazySizes.getX(elem); var x = Math.min(optimum || dpr, 2.2, dpr); - if(x < 1.2){ - x *= 1.05; + if(x < 1.25){ + x *= 1.1; } else if(x > 1.6 && !optimum){ - x *= 0.95; + x *= 0.9; } return x; diff --git a/plugins/rias/ls.rias.min.js b/plugins/rias/ls.rias.min.js index ad579cc5..03baf297 100644 --- a/plugins/rias/ls.rias.min.js +++ b/plugins/rias/ls.rias.min.js @@ -1,2 +1,2 @@ -/*! lazysizes - v1.1.0-rc3 - Licensed MIT */ -!function(a,b){"use strict";function c(a,b){var c,d,e,f;d=a.parentNode,f={isPicture:!(!d||!l.test(d.nodeName||""))},e=function(b,c){var d=a.getAttribute("data-"+b);if(null!=d){if("true"==d)d=!0;else if("false"==d)d=!1;else if(k.test(d))d=parseFloat(d);else if("function"==typeof i[b])d=i[b](a,d);else if(o.test(d))try{d=JSON.parse(d)}catch(e){}f[b]=d}else b in i&&"function"!=typeof i[b]?f[b]=i[b]:c&&"function"==typeof i[b]&&(f[b]=i[b](a,d))};for(c in i)e(c);return b.replace(n,function(a,b){b in f||e(b,!0)}),f}function d(a,b){var c=[],d=function(a,c){return j[typeof b[c]]?b[c]:a};return c.srcset=[],b.absUrl&&(q.setAttribute("href",a),a=q.href),a=((b.prefix||"")+a+(b.postfix||"")).replace(n,d),b.widths.forEach(function(d){var e={u:a.replace(m,b.widthmap[d]||d),w:d};c.push(e),c.srcset.push(e.c=e.u+" "+d+"w")}),c}function e(a,b,c){a&&(a=d(a,b),a.isPicture=b.isPicture,c.setAttribute(h.srcsetAttr,a.srcset.join(", ")),Object.defineProperty(c,"_lazyrias",{value:a,writable:!0}))}function f(a,b){var d=c(a,b);return i.modifyOptions.call(a,{target:a,details:d,detail:d}),lazySizes.fire(a,"lazyriasmodifyoptions",d),d}function g(a){return a.getAttribute(a.getAttribute("data-srcattr")||i.srcAttr)||a.getAttribute(h.srcsetAttr)||a.getAttribute(h.srcAttr)||""}if(b.addEventListener){var h,i,j={string:1,number:1},k=/^\-*\+*\d+\.*\d*$/,l=/^picture$/i,m=/\s*\{\s*width\s*\}\s*/i,n=/\s*\{\s*([a-z0-9]+)\s*\}\s*/gi,o=/^\[.*\]|\{.*\}$/,p=/^(?:auto|\d+(px)?)$/,q=b.createElement("a");!function(){var b,c=function(){},d={prefix:"",postfix:"",srcAttr:"data-src",absUrl:!1,modifyOptions:c,widthmap:{}};h=a.lazySizes&&lazySizes.cfg||a.lazySizesConfig,h||(h={},a.lazySizesConfig=h),h.supportsType||(h.supportsType=function(a){return!a}),h.rias||(h.rias={}),i=h.rias,"widths"in i||(i.widths=[],function(a){var b,c=0;for(a.push(96);!b||2800>b;)c+=10,c>60&&(c+=10),b=16*c,a.push(b)}(i.widths));for(b in d)b in i||(i[b]=d[b])}(),addEventListener("lazybeforeunveil",function(a){var b,c,d,j,k,l,n,o,q,s;if(b=a.target,!a.defaultPrevented&&(c=g(b))&&!i.disabled&&(q=b.getAttribute(h.sizesAttr)||b.getAttribute("sizes"))&&p.test(q)){if(d=f(b,c),m.test(c)||m.test(d.prefix)||m.test(d.postfix)){if(d.isPicture&&(j=b.parentNode))for(k=j.getElementsByTagName("source"),l=0,n=k.length;n>l;l++)o=g(k[l]),e(o,d,k[l]);e(c,d,b)}"auto"!=q&&(s={width:parseInt(q,10)},r({target:b,detail:s,details:s}))}});var r=function(){var c=function(a,b,c,d){return Math.abs(b.w-d.w)e?e*=1.05:e>1.6&&!d&&(e*=.95),e},f=function(b,f){var g,h,i,j,k;if(f=Math.round(f*e(b)),k=b._lazyrias,k.isPicture&&a.matchMedia)for(h=0,g=b.parentNode.getElementsByTagName("source"),i=g.length;i>h;h++)if(d(g[h])&&!g[h].getAttribute("type")&&(!(j=g[h].getAttribute("media"))||(matchMedia(j)||{}).matches)){k=g[h]._lazyrias;break}return(!k.w||k.wb;)c+=10,c>60&&(c+=10),b=16*c,a.push(b)}(i.widths));for(b in d)b in i||(i[b]=d[b])}(),addEventListener("lazybeforeunveil",function(a){var b,c,d,j,k,l,n,o,q,s;if(b=a.target,!a.defaultPrevented&&(c=g(b))&&!i.disabled&&(q=b.getAttribute(h.sizesAttr)||b.getAttribute("sizes"))&&p.test(q)){if(d=f(b,c),m.test(c)||m.test(d.prefix)||m.test(d.postfix)){if(d.isPicture&&(j=b.parentNode))for(k=j.getElementsByTagName("source"),l=0,n=k.length;n>l;l++)o=g(k[l]),e(o,d,k[l]);e(c,d,b)}"auto"!=q&&(s={width:parseInt(q,10)},r({target:b,detail:s,details:s}))}});var r=function(){var c=function(a,b,c,d){return Math.abs(b.w-d.w)e?e*=1.1:e>1.6&&!d&&(e*=.9),e},f=function(b,f){var g,h,i,j,k;if(f=Math.round(f*e(b)),k=b._lazyrias,k.isPicture&&a.matchMedia)for(h=0,g=b.parentNode.getElementsByTagName("source"),i=g.length;i>h;h++)if(d(g[h])&&!g[h].getAttribute("type")&&(!(j=g[h].getAttribute("media"))||(matchMedia(j)||{}).matches)){k=g[h]._lazyrias;break}return(!k.w||k.we;e++)a[c[e]]&&Object.defineProperty(d,c[e],{value:a[c[e]],writable:!0});f.appendChild(d),null!=h&&d.setAttribute("srcset",h),null!=g&&d.setAttribute("src",g)},e=function(){var a,b=document.querySelectorAll("picture > img");for(a=0;a