Skip to content

Commit 71a5151

Browse files
committed
fix handling of hidden elements by row, closes #28
1 parent 56214a1 commit 71a5151

File tree

2 files changed

+13
-13
lines changed

2 files changed

+13
-13
lines changed

jquery.matchHeight-min.js

+5-5
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

jquery.matchHeight.js

+8-8
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,10 @@
123123
var scrollTop = $(window).scrollTop(),
124124
htmlHeight = $('html').outerHeight(true);
125125

126+
// temporarily must force hidden parents visible
127+
var $hiddenParents = $elements.parents().filter(':hidden');
128+
$hiddenParents.css('display', 'block');
129+
126130
// get rows if using byRow, otherwise assume one row
127131
if (byRow) {
128132

@@ -164,10 +168,6 @@
164168
if (byRow && $row.length <= 1)
165169
return;
166170

167-
// ensure elements are visible to prevent 0 height
168-
var hiddenParents = $row.parents().add($row).filter(':hidden');
169-
hiddenParents.css({ 'display': 'block' });
170-
171171
// iterate the row and find the max height
172172
$row.each(function(){
173173
var $that = $(this),
@@ -181,12 +181,9 @@
181181
maxHeight = $that.outerHeight(false);
182182

183183
// revert display block
184-
$that.css({ 'display': '' });
184+
$that.css('display', '');
185185
});
186186

187-
// revert display block
188-
hiddenParents.css({ 'display': '' });
189-
190187
// iterate the row and apply the height to all elements
191188
$row.each(function(){
192189
var $that = $(this),
@@ -203,6 +200,9 @@
203200
});
204201
});
205202

203+
// revert hidden parents
204+
$hiddenParents.css('display', '');
205+
206206
// restore scroll position if enabled
207207
if ($.fn.matchHeight._maintainScroll)
208208
$(window).scrollTop((scrollTop / htmlHeight) * $('html').outerHeight(true));

0 commit comments

Comments
 (0)