diff --git a/lazysizes.js b/lazysizes.js index 386ee59b..6fd96f87 100644 --- a/lazysizes.js +++ b/lazysizes.js @@ -382,7 +382,7 @@ } var onload = function(){ - inViewLow = Math.max( Math.min(lazySizesConfig.threshold || 150, 300), 40 ); + inViewLow = Math.max( Math.min(lazySizesConfig.threshold || 150, 300), 9 ); inViewHigh = Math.min( inViewLow * 7, Math.max(innerHeight * 1.3, docElem.clientHeight * 1.3, inViewLow * 4) ); isWinloaded = /d$|^c/.test(document.readyState); inViewThreshold = isWinloaded ? inViewHigh : inViewLow; diff --git a/lazysizes.min.js b/lazysizes.min.js index 2c915586..e4bcf47c 100644 --- a/lazysizes.min.js +++ b/lazysizes.min.js @@ -1,3 +1,3 @@ /*! lazysizes - v0.7.2 - 2015-01-10 Licensed MIT */ -!function(a){window.lazySizes=a(window),"function"==typeof define&&define.amd&&define(window.lazySizes)}(function(a){"use strict";function b(b,c){var d;a.HTMLPictureElement||(a.picturefill?picturefill({reevaluate:!0,reparse:!0,elements:[b]}):a.respimage?(c&&(d=b[respimage._.ns],d&&(d[c.srcset?"srcset":"src"]=void 0)),respimage({reparse:!0,elements:[b]})):c&&c.src&&(b.src=c.src))}function c(a,b){return getComputedStyle(a,null)[b]}function d(a,c){var d,f,g,h,j,m,o,p,w,x,y=a.currentSrc||a.src,z=u.test(a.nodeName);if(s||n||!z||!y||a.complete){if(!(x=C(a,"lazybeforeunveil",{force:!!c})).defaultPrevented&&(j=a.getAttribute(i.sizesAttr)||a.getAttribute("sizes"),j&&("auto"==j?e(a,!0):a.setAttribute("sizes",j),i.clearAttr&&a.removeAttribute(i.sizesAttr)),o=a.getAttribute(i.srcsetAttr),m=a.getAttribute(i.srcAttr),q++,B(a,M,!0),clearTimeout(E),E=setTimeout(M,3e3),z&&(p=a.parentNode,w=t.test(p.nodeName||"")),z&&(k(a,i.loadingClass),B(a,Q,!0)),o||m)){if(w)for(d=p.getElementsByTagName("source"),f=0,g=d.length;g>f;f++)h=d[f].getAttribute(i.srcsetAttr),h&&d[f].setAttribute("srcset",h);o?(a.setAttribute("srcset",o),r&&j&&a.removeAttribute("src"),i.clearAttr&&a.removeAttribute(i.srcsetAttr)):m&&(a.setAttribute("src",m),i.clearAttr&&a.removeAttribute(i.srcAttr))}setTimeout(function(){l(a,i.lazyClass),"auto"==j&&k(a,i.autosizesClass),(o||j)&&b(a,{srcset:o,src:m}),a.lazyload&&(a.lazyload=0),x.details.firesLoad||v.test(a.nodeName)&&(o||m)&&(!a.complete||y!=(a.currentSrc||a.src))||(i.addClasses&&Q({target:a}),M({target:a})),a=null})}}function e(a,c){var d,e,f,g,h,j=a.parentNode;if(j&&(d=T(a,j),h=C(a,"lazybeforesizes",{width:d,dataAttr:!!c}),!h.defaultPrevented&&(d=h.details.width,d&&d!==a._lazysizesWidth&&(!i.onlyLargerSizes||!a._lazysizesWidth||a._lazysizesWidthf;f++)e[f].setAttribute("sizes",d);h.details.dataAttr||b(a)}}if(a.document.getElementsByClassName){var f,g,h,i,j,k,l,m,n,o=a.document,p=o.documentElement,q=0,r=a.HTMLPictureElement&&navigator.userAgent.match(/hrome\/(\d+)/)&&40==RegExp.$1,s=/blink|webkit/i.test(navigator.userAgent),t=/^picture$/i,u=/^img$/i,v=/^(?:img|iframe)$/i,w=-2,x=w,y=40,z=0,A=0,B=function(a,b,c){var d=c?"addEventListener":"removeEventListener";c&&B(a,b),["load","error","lazyincluded","_lazyloaded"].forEach(function(c){a[d](c,b,!0)})},C=function(a,b,c){var d=o.createEvent("Event");return d.initEvent(b,!0,!0),d.details=c||{},a.dispatchEvent(d),d};k=function(a,b){m(a,b)||(a.className+=" "+b)},l=function(a,b){var c;(c=m(a,b))&&(a.className=a.className.replace(c," "))},m=function(a,b){var c=new RegExp("(\\s|^)"+b+"(\\s|$)");return a.className.match(c)&&c};var D,E,F,G,H,I,J,K,L,M=function(a){q--,a&&a.target&&B(a.target,M),(!a||0>q||!a.target)&&(q=0)},N=function(){var a,b,c=function(){clearTimeout(a),A=0,P(),b=!1};return function(){b||(b=!0,clearTimeout(a),a=setTimeout(c,66))}}(),O=function(a){var b,d=a,e="hidden"!=c(a,"visibility"),f=3>q?x:-2;for(H-=f,K+=f,I-=f,J+=f;e&&(d=d.offsetParent)&&d!=p&&d!=o.body;)e=(c(d,"opacity")||1)>0,e&&"visible"!=c(d,"overflow")&&(b=d.getBoundingClientRect(),e=J>b.left-1&&Ib.top-1&&HA;A++)q>3&&x>0&&(x=-2,F=innerWidth+x,G=innerHeight+x,L=2),a=f[A].getBoundingClientRect(),(K=a.bottom)>=L&&(H=a.top)<=G&&(J=a.right)>=L&&(I=a.left)<=F&&(K||J||I||H)&&(n&&x==w&&3>q&&9>z||O(f[A]))?(d(f[A]),c=!0):!c&&n&&!b&&3>q&&9>z&&(h[0]||i.preloadAfterLoad)&&(h[0]||K||J||I||H||"auto"!=f[A].getAttribute(i.sizesAttr))&&(b=h[0]||f[A]);z++,y>x&&2>q&&z>9?(x=y,z=0,setTimeout(N)):x!=w&&(x=w),b&&!c&&d(b)}},Q=function(a){k(a.target,i.loadedClass),l(a.target,i.loadingClass),B(a.target,Q)},R=function(){var a,b=function(){clearTimeout(a),j=0,S()};return function(){clearTimeout(a),a=setTimeout(b,99)}}(),S=function(){var a,b=g.length;if(b)for(a=j||0;b>a;a++)e(g[a])},T=function(a,b){var c,d;for(a._lazysizesWidth||(d=a.getAttribute("alt"),a.alt=""),c=a.offsetWidth;cf;f++)h=d[f].getAttribute(i.srcsetAttr),h&&d[f].setAttribute("srcset",h);o?(a.setAttribute("srcset",o),r&&j&&a.removeAttribute("src"),i.clearAttr&&a.removeAttribute(i.srcsetAttr)):m&&(a.setAttribute("src",m),i.clearAttr&&a.removeAttribute(i.srcAttr))}setTimeout(function(){l(a,i.lazyClass),"auto"==j&&k(a,i.autosizesClass),(o||j)&&b(a,{srcset:o,src:m}),a.lazyload&&(a.lazyload=0),x.details.firesLoad||v.test(a.nodeName)&&(o||m)&&(!a.complete||y!=(a.currentSrc||a.src))||(i.addClasses&&Q({target:a}),M({target:a})),a=null})}}function e(a,c){var d,e,f,g,h,j=a.parentNode;if(j&&(d=T(a,j),h=C(a,"lazybeforesizes",{width:d,dataAttr:!!c}),!h.defaultPrevented&&(d=h.details.width,d&&d!==a._lazysizesWidth&&(!i.onlyLargerSizes||!a._lazysizesWidth||a._lazysizesWidthf;f++)e[f].setAttribute("sizes",d);h.details.dataAttr||b(a)}}if(a.document.getElementsByClassName){var f,g,h,i,j,k,l,m,n,o=a.document,p=o.documentElement,q=0,r=a.HTMLPictureElement&&navigator.userAgent.match(/hrome\/(\d+)/)&&40==RegExp.$1,s=/blink|webkit/i.test(navigator.userAgent),t=/^picture$/i,u=/^img$/i,v=/^(?:img|iframe)$/i,w=-2,x=w,y=40,z=0,A=0,B=function(a,b,c){var d=c?"addEventListener":"removeEventListener";c&&B(a,b),["load","error","lazyincluded","_lazyloaded"].forEach(function(c){a[d](c,b,!0)})},C=function(a,b,c){var d=o.createEvent("Event");return d.initEvent(b,!0,!0),d.details=c||{},a.dispatchEvent(d),d};k=function(a,b){m(a,b)||(a.className+=" "+b)},l=function(a,b){var c;(c=m(a,b))&&(a.className=a.className.replace(c," "))},m=function(a,b){var c=new RegExp("(\\s|^)"+b+"(\\s|$)");return a.className.match(c)&&c};var D,E,F,G,H,I,J,K,L,M=function(a){q--,a&&a.target&&B(a.target,M),(!a||0>q||!a.target)&&(q=0)},N=function(){var a,b,c=function(){clearTimeout(a),A=0,P(),b=!1};return function(){b||(b=!0,clearTimeout(a),a=setTimeout(c,66))}}(),O=function(a){var b,d=a,e="hidden"!=c(a,"visibility"),f=3>q?x:-2;for(H-=f,K+=f,I-=f,J+=f;e&&(d=d.offsetParent)&&d!=p&&d!=o.body;)e=(c(d,"opacity")||1)>0,e&&"visible"!=c(d,"overflow")&&(b=d.getBoundingClientRect(),e=J>b.left-1&&Ib.top-1&&HA;A++)q>3&&x>0&&(x=-2,F=innerWidth+x,G=innerHeight+x,L=2),a=f[A].getBoundingClientRect(),(K=a.bottom)>=L&&(H=a.top)<=G&&(J=a.right)>=L&&(I=a.left)<=F&&(K||J||I||H)&&(n&&x==w&&3>q&&9>z||O(f[A]))?(d(f[A]),c=!0):!c&&n&&!b&&3>q&&9>z&&(h[0]||i.preloadAfterLoad)&&(h[0]||K||J||I||H||"auto"!=f[A].getAttribute(i.sizesAttr))&&(b=h[0]||f[A]);z++,y>x&&2>q&&z>9?(x=y,z=0,setTimeout(N)):x!=w&&(x=w),b&&!c&&d(b)}},Q=function(a){k(a.target,i.loadedClass),l(a.target,i.loadingClass),B(a.target,Q)},R=function(){var a,b=function(){clearTimeout(a),j=0,S()};return function(){clearTimeout(a),a=setTimeout(b,99)}}(),S=function(){var a,b=g.length;if(b)for(a=j||0;b>a;a++)e(g[a])},T=function(a,b){var c,d;for(a._lazysizesWidth||(d=a.getAttribute("alt"),a.alt=""),c=a.offsetWidth;c