Skip to content

Commit 72ba5cf

Browse files
committed
Preserve inline styles when using byRow
1 parent fdc8f7a commit 72ba5cf

File tree

1 file changed

+14
-18
lines changed

1 file changed

+14
-18
lines changed

jquery.matchHeight.js

+14-18
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313
_updateTimeout = -1;
1414

1515
/*
16-
* _rows
17-
* utility function returns array of jQuery selections representing each row
16+
* _rows
17+
* utility function returns array of jQuery selections representing each row
1818
* (as displayed after float wrapping applied by browser)
1919
*/
2020

@@ -131,7 +131,7 @@
131131
var $that = $(this),
132132
display = $that.css('display') === 'inline-block' ? 'inline-block' : 'block';
133133

134-
$that.css({
134+
$that.data('original_style', $that.attr('style')).css({
135135
'display': display,
136136
'padding-top': '0',
137137
'padding-bottom': '0',
@@ -144,14 +144,10 @@
144144
// get the array of rows (based on element top position)
145145
rows = _rows($elements);
146146

147-
// revert the temporary forced style
148-
$elements.css({
149-
'display': '',
150-
'padding-top': '',
151-
'padding-bottom': '',
152-
'border-top-width': '',
153-
'border-bottom-width': '',
154-
'height': ''
147+
$elements.each(function() {
148+
var $that = $(this);
149+
150+
$that.attr('style', $that.data('original_style'));
155151
});
156152
}
157153

@@ -213,7 +209,7 @@
213209
* $.fn.matchHeight._applyDataApi
214210
* applies matchHeight to all elements with a data-match-height attribute
215211
*/
216-
212+
217213
$.fn.matchHeight._applyDataApi = function() {
218214
var groups = {};
219215

@@ -234,7 +230,7 @@
234230
});
235231
};
236232

237-
/*
233+
/*
238234
* $.fn.matchHeight._update
239235
* updates matchHeight on all current groups with their correct options
240236
*/
@@ -246,7 +242,7 @@
246242
};
247243

248244
$.fn.matchHeight._update = function(throttle, event) {
249-
// prevent update if fired from a resize event
245+
// prevent update if fired from a resize event
250246
// where the viewport width hasn't actually changed
251247
// fixes an event looping bug in IE8
252248
if (event && event.type === 'resize') {
@@ -267,21 +263,21 @@
267263
}
268264
};
269265

270-
/*
266+
/*
271267
* bind events
272268
*/
273269

274270
// apply on DOM ready event
275271
$($.fn.matchHeight._applyDataApi);
276272

277273
// update heights on load and resize events
278-
$(window).bind('load', function(event) {
274+
$(window).bind('load', function(event) {
279275
$.fn.matchHeight._update();
280276
});
281277

282278
// throttled update heights on resize events
283-
$(window).bind('resize orientationchange', function(event) {
279+
$(window).bind('resize orientationchange', function(event) {
284280
$.fn.matchHeight._update(true, event);
285281
});
286282

287-
})(jQuery);
283+
})(jQuery);

0 commit comments

Comments
 (0)