Skip to content

Commit

Permalink
small improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
aFarkas committed Jan 28, 2015
1 parent 59bcab1 commit 70b4ed6
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ Here the list of options:
* ``lazySizesConfig.addClasses`` (default: ``true``): Wether lazysizes should add loading and loaded classes. This can be used to add unveil effects or to apply new styles (background-image).
* ``lazySizesConfig.loadingClass`` (default: ``"lazyloading"``): If ``addClasses`` is set to ``true`` 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"``): If ``addClasses`` is set to ``true`` 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: ``150``): 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 ``30`` and ``200``.) 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 (by multiplying the ``expand`` option with ``3.5``) if the browser network is currently idling. This option can be overridden with the ``[data-expand]`` attribute.
* ``lazySizesConfig.expand`` (default: ``120``): 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 ``20`` and ``180``.) 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 (by multiplying the ``expand`` option with ``3.5``) if the browser network is currently idling. This option can be overridden with the ``[data-expand]`` attribute.
* ``lazySizesConfig.minSize`` (default: ``50``): For ``data-sizes="auto"`` feature. The minimum size of an image that is used to calculate the ``sizes`` attribute. In case it is under ``minSize`` the script traverses up the DOM tree until it finds a parent that is over ``minSize``.
* ``lazySizesConfig.srcAttr`` (default: ``"data-src"``): The attribute, which should be transformed to ``src``.
* ``lazySizesConfig.srcset`` (default: ``"data-srcset"``): The attribute, which should be transformed to ``srcset``.
Expand Down
14 changes: 7 additions & 7 deletions lazysizes.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@
}
};

document.addEventListener("visibilitychange", handleVisibility);
document.addEventListener('visibilitychange', handleVisibility);
handleVisibility();

return function(force){
Expand All @@ -126,7 +126,7 @@

var ua = navigator.userAgent;
var fixChrome = window.HTMLPictureElement && ua.match(/hrome\/(\d+)/) && (RegExp.$1 == 40);
var supportNativeLQIP = (/blink|webkit/i).test(ua);
var supportNativeLQIP = (/webkit/i).test(ua);

var regImg = /^img$/i;
var regIframe = /^iframe$/i;
Expand Down Expand Up @@ -359,7 +359,7 @@
addClass(elem, lazySizesConfig.autosizesClass);
}

if(srcset || sizes || isPicture){
if(srcset || isPicture){
updatePolyfill(elem, {srcset: srcset, src: src});
}

Expand All @@ -368,10 +368,10 @@
//remove curSrc == (elem.currentSrc || elem.src) it's a workaround for FF. see: https://bugzilla.mozilla.org/show_bug.cgi?id=608261
if( !firesLoad || (elem.complete && curSrc == (elem.currentSrc || elem.src)) ){
if(firesLoad){
resetPreloading({target: elem});
resetPreloading(event);
}
if(lazySizesConfig.addClasses){
switchLoadingClass({target: elem});
switchLoadingClass(event);
}
}
elem = null;
Expand All @@ -381,8 +381,8 @@
var calcExpand = function(){

if(isPreloadAllowed && !isExpandCalculated){
defaultExpand = Math.max( Math.min(lazySizesConfig.expand || lazySizesConfig.threshold || 150, 300), 9 );
preloadExpand = Math.min( defaultExpand * 4, Math.max(innerHeight * 1.1, docElem.clientHeight, defaultExpand * 3) );
defaultExpand = Math.max( Math.min(lazySizesConfig.expand || lazySizesConfig.threshold || 120, 300), 9 );
preloadExpand = defaultExpand * 4;
}

isExpandCalculated = true;
Expand Down
2 changes: 1 addition & 1 deletion lazysizes.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 70b4ed6

Please sign in to comment.