Skip to content

Commit

Permalink
Merge pull request #15 from aurora/fix-resize
Browse files Browse the repository at this point in the history
Resize does not work properly, if width/height attribute are not set on the image tag
  • Loading branch information
brunjo committed Nov 11, 2014
2 parents a68d0c4 + 7f07e42 commit d7adae1
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions jquery.row-grid.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
// read
var containerWidth = container.clientWidth-parseFloat($(container).css('padding-left'))-parseFloat($(container).css('padding-right'));
var itemAttrs = [];
var theImage;
var theImage, w, h;
for(var i = 0; i < itemsSize; ++i) {
theImage = items[i].getElementsByTagName('img')[0];
if (!theImage) {
Expand All @@ -47,9 +47,16 @@
continue;
}
// get width and height via attribute or js value
if (!(w = parseInt(theImage.getAttribute('width')))) {
theImage.setAttribute('width', w = theImage.offsetWidth);
}
if (!(h = parseInt(theImage.getAttribute('height')))) {
theImage.setAttribute('height', h = theImage.offsetHeight);
}

itemAttrs[i] = {
width: parseInt(theImage.getAttribute('width')) || theImage.offsetWidth,
height: parseInt(theImage.getAttribute('height')) || theImage.offsetHeight
width: w,
height: h
};
}
itemsSize = items.length;
Expand Down

0 comments on commit d7adae1

Please sign in to comment.