From 8f5f13f096480d042a57d5a669177ea545c7eabd Mon Sep 17 00:00:00 2001 From: liabru Date: Fri, 2 May 2014 00:05:39 +0100 Subject: [PATCH] added matchHeight('remove') --- jquery.matchHeight.js | 18 ++++++++++++++++++ test.css | 5 +++++ test.html | 12 ++++++++++++ 3 files changed, 35 insertions(+) diff --git a/jquery.matchHeight.js b/jquery.matchHeight.js index 28532a7..6ff0065 100644 --- a/jquery.matchHeight.js +++ b/jquery.matchHeight.js @@ -7,6 +7,24 @@ (function($) { $.fn.matchHeight = function(byRow) { + + // handle matchHeight('remove') + if (byRow === 'remove') { + var that = this; + + // remove fixed height from all selected elements + this.css('height', ''); + + // remove selected elements from all groups + $.each($.fn.matchHeight._groups, function(key, group) { + group.elements = group.elements.not(that); + }); + + // TODO: cleanup empty groups + + return this; + } + if (this.length <= 1) return this; diff --git a/test.css b/test.css index 35d9e51..49b863a 100644 --- a/test.css +++ b/test.css @@ -69,6 +69,11 @@ a, a:link, a:visited, a:active, a:hover { margin: 5px 20px 5px 0; } +.test-remove { + padding: 5px; + margin: -5px 20px; +} + /* test items */ .items-container, diff --git a/test.html b/test.html index 4394f4a..74e0022 100644 --- a/test.html +++ b/test.html @@ -28,6 +28,13 @@ $('.items-container').each(function() { $(this).children('.item').matchHeight(byRow); }); + + // example of removing matchHeight + $('.test-remove').click(function() { + $('.items-container').each(function() { + $(this).children('.item').matchHeight('remove'); + }); + }); }); })(); @@ -77,6 +84,11 @@

jquery.matchHeight Tests

by row +
+ +