Skip to content

Commit

Permalink
fix handling of hidden elements by row, closes #28
Browse files Browse the repository at this point in the history
  • Loading branch information
liabru committed Sep 16, 2014
1 parent 56214a1 commit 71a5151
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
10 changes: 5 additions & 5 deletions jquery.matchHeight-min.js

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

16 changes: 8 additions & 8 deletions jquery.matchHeight.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,10 @@
var scrollTop = $(window).scrollTop(),
htmlHeight = $('html').outerHeight(true);

// temporarily must force hidden parents visible
var $hiddenParents = $elements.parents().filter(':hidden');
$hiddenParents.css('display', 'block');

// get rows if using byRow, otherwise assume one row
if (byRow) {

Expand Down Expand Up @@ -164,10 +168,6 @@
if (byRow && $row.length <= 1)
return;

// ensure elements are visible to prevent 0 height
var hiddenParents = $row.parents().add($row).filter(':hidden');
hiddenParents.css({ 'display': 'block' });

// iterate the row and find the max height
$row.each(function(){
var $that = $(this),
Expand All @@ -181,12 +181,9 @@
maxHeight = $that.outerHeight(false);

// revert display block
$that.css({ 'display': '' });
$that.css('display', '');
});

// revert display block
hiddenParents.css({ 'display': '' });

// iterate the row and apply the height to all elements
$row.each(function(){
var $that = $(this),
Expand All @@ -203,6 +200,9 @@
});
});

// revert hidden parents
$hiddenParents.css('display', '');

// restore scroll position if enabled
if ($.fn.matchHeight._maintainScroll)
$(window).scrollTop((scrollTop / htmlHeight) * $('html').outerHeight(true));
Expand Down

0 comments on commit 71a5151

Please sign in to comment.