Skip to content

Commit

Permalink
2.0.2
Browse files Browse the repository at this point in the history
  • Loading branch information
alexander.farkas committed Sep 2, 2016
1 parent c4b5529 commit 181d38d
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 11 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "lazysizes",
"version": "2.0.2-rc1",
"version": "2.0.2",
"filename": "lazysizes.min.js",
"author": "Alexander Farkas <info@corrupt-system.de>",
"repository": {
Expand Down
2 changes: 1 addition & 1 deletion plugins/aspectratio/ls.aspectratio.min.js

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

24 changes: 20 additions & 4 deletions plugins/object-fit/ls.object-fit.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
}

function initFix(element, config){
var switchClassesAdded;
var lazysizesCfg = lazySizes.cfg;
var styleElement = element.cloneNode(false);
var styleElementStyle = styleElement.style;

Expand All @@ -36,6 +38,12 @@

if(src){
styleElementStyle.backgroundImage = 'url(' + src + ')';

if(!switchClassesAdded){
switchClassesAdded = true;
lazySizes.rC(styleElement, lazysizesCfg.loadingClass);
lazySizes.aC(styleElement, lazysizesCfg.loadedClass);
}
}
};

Expand Down Expand Up @@ -64,10 +72,18 @@
container = container.parentNode;
}

lazySizes.rC(styleElement, lazySizes.cfg.loadingClass);
lazySizes.rC(styleElement, lazySizes.cfg.loadedClass);
lazySizes.rC(styleElement, lazySizes.cfg.lazyClass);
lazySizes.aC(styleElement, lazySizes.cfg.objectFitClass || 'lazysizes-display-clone');
lazySizes.rC(styleElement, lazysizesCfg.loadedClass);
lazySizes.rC(styleElement, lazysizesCfg.lazyClass);
lazySizes.aC(styleElement, lazysizesCfg.loadingClass);
lazySizes.aC(styleElement, lazysizesCfg.objectFitClass || 'lazysizes-display-clone');

if(styleElement.getAttribute(lazysizesCfg.srcsetAttr)){
styleElement.setAttribute(lazysizesCfg.srcsetAttr, '');
}

if(styleElement.getAttribute(lazysizesCfg.srcAttr)){
styleElement.setAttribute(lazysizesCfg.srcAttr, '');
}

styleElement.src = blankSrc;
styleElement.srcset = '';
Expand Down
4 changes: 2 additions & 2 deletions plugins/object-fit/ls.object-fit.min.js

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

5 changes: 4 additions & 1 deletion plugins/respimg/ls.respimg.js
Original file line number Diff line number Diff line change
Expand Up @@ -256,9 +256,12 @@
width = source.getAttribute('sizes') || '';
width = regPxLength.test(width) && parseInt(width, 10) || lazySizes.gW(elem, elem.parentNode);
srces.d = getX(elem);
if(!srces.w || srces.w < width){
if(!srces.src || !srces.w || srces.w < width){
srces.w = width;
src = reduceCandidate(srces.sort(ascendingSort));
srces.src = src;
} else {
src = srces.src;
}
} else {
src = srces[0];
Expand Down
4 changes: 2 additions & 2 deletions plugins/respimg/ls.respimg.min.js

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

0 comments on commit 181d38d

Please sign in to comment.