Skip to content

Commit

Permalink
fix hidden element bug on firefox/IE
Browse files Browse the repository at this point in the history
  • Loading branch information
jrmd committed Apr 29, 2016
1 parent 7ba412f commit 6a2a865
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 17 deletions.
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "macy",
"version": "1.1.1",
"version": "1.1.2",
"homepage": "http://macyjs.com/",
"author": {
"name": "Big Bite Creative",
Expand Down
16 changes: 9 additions & 7 deletions dist/macy.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*!
* Macy.js v1.1.1 - Macy is a lightweight, dependency free, masonry layout library
* Macy.js v1.1.2 - Macy is a lightweight, dependency free, masonry layout library
* Author: Copyright (c) Big Bite Creative <@bigbitecreative> <http://bigbitecreative.com>
* Url: http://macyjs.com/
* License: MIT
Expand Down Expand Up @@ -39,7 +39,7 @@
return extended;
};
var Macy = {};
Macy.VERSION = "1.1.1";
Macy.VERSION = "1.1.2";
Macy.settings = {};
var defaults = {
columns: 3,
Expand Down Expand Up @@ -100,12 +100,13 @@
};
var getTopValue = function(row, col, eles) {
var totalHeight = 0;
var tempHeight;
if (row === 0) {
return 0;
}
for (var i = 0; i < row; i++) {
totalHeight += parseInt(getProperty(cache.elements[eles[i]], "height").replace("px", ""));
totalHeight += cache.options.margin;
tempHeight = parseInt(getProperty(cache.elements[eles[i]], "height").replace("px", ""), 10);
totalHeight += isNaN(tempHeight) ? 0 : tempHeight + cache.options.margin;
}
return totalHeight;
};
Expand Down Expand Up @@ -169,10 +170,11 @@
};
var findIndexOfSmallestTotal = function(arr) {
var runningTotal = 0;
var smallestIndex, smallest, lastSmall;
var smallestIndex, smallest, lastSmall, tempHeight;
for (var i = 0, arrLen = arr.length; i < arrLen; i++) {
for (var j = 0; j < arr[i].length; j++) {
runningTotal += parseInt(getProperty(cache.elements[arr[i][j]], "height").replace("px", ""));
tempHeight = parseInt(getProperty(cache.elements[arr[i][j]], "height").replace("px", ""), 10);
runningTotal += isNaN(tempHeight) ? 0 : tempHeight;
}
lastSmall = smallest;
smallest = smallest === undefined ? runningTotal : smallest > runningTotal ? runningTotal : smallest;
Expand All @@ -191,7 +193,7 @@
var highest = 0, runningTotal = 0;
for (var i = 0, arrLen = arr.length; i < arrLen; i++) {
for (var j = 0; j < arr[i].length; j++) {
runningTotal += parseInt(getProperty(cache.elements[arr[i][j]], "height").replace("px", ""));
runningTotal += parseInt(getProperty(cache.elements[arr[i][j]], "height").replace("px", ""), 10);
runningTotal += j !== 0 ? cache.options.margin : 0;
}
highest = highest < runningTotal ? runningTotal : highest;
Expand Down
4 changes: 2 additions & 2 deletions dist/macy.min.js

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "macy",
"description": "Macy is a lightweight, dependency free, masonry layout library",
"version": "1.1.1",
"version": "1.1.2",
"author": {
"name": "Big Bite Creative",
"url": "http://bigbitecreative.com",
Expand Down
14 changes: 8 additions & 6 deletions src/macy.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
* Current version.
* @type {String}
*/
Macy.VERSION = '1.1.1';
Macy.VERSION = '1.1.2';

/**
* Expose settings.
Expand Down Expand Up @@ -170,14 +170,15 @@
*/
var getTopValue = function (row, col, eles) {
var totalHeight = 0;
var tempHeight;

if (row === 0) {
return 0;
}

for (var i = 0; i < row; i++) {
totalHeight += parseInt(getProperty(cache.elements[eles[i]], 'height').replace('px', ''));
totalHeight += cache.options.margin;
tempHeight = parseInt(getProperty(cache.elements[eles[i]], 'height').replace('px', ''), 10);
totalHeight += isNaN(tempHeight) ? 0 : tempHeight + cache.options.margin;
}

return totalHeight;
Expand Down Expand Up @@ -278,11 +279,12 @@
*/
var findIndexOfSmallestTotal = function (arr) {
var runningTotal = 0;
var smallestIndex, smallest, lastSmall;
var smallestIndex, smallest, lastSmall, tempHeight;

for (var i = 0, arrLen = arr.length; i < arrLen; i++) {
for (var j = 0; j < arr[i].length; j++) {
runningTotal += parseInt(getProperty(cache.elements[arr[i][j]], 'height').replace('px', ''));
tempHeight = parseInt(getProperty(cache.elements[arr[i][j]], 'height').replace('px', ''), 10);
runningTotal += isNaN(tempHeight) ? 0 : tempHeight;
}

lastSmall = smallest;
Expand Down Expand Up @@ -317,7 +319,7 @@

for (var i = 0, arrLen = arr.length; i < arrLen; i++) {
for (var j = 0; j < arr[i].length; j++) {
runningTotal += parseInt(getProperty(cache.elements[arr[i][j]], 'height').replace('px', ''));
runningTotal += parseInt(getProperty(cache.elements[arr[i][j]], 'height').replace('px', ''), 10);
runningTotal += j !== 0 ? cache.options.margin : 0;
}

Expand Down

0 comments on commit 6a2a865

Please sign in to comment.