diff options
author | Oliver Sartun <sartun@dievision.de> | 2015-11-11 20:39:31 +0100 |
---|---|---|
committer | Oliver Sartun <sartun@dievision.de> | 2015-11-11 20:39:31 +0100 |
commit | bf409366fe03b983188676d973fef900057af35e (patch) | |
tree | 720616a2d0915127dfbaa2ff6c239e759bbcacc5 | |
parent | 69d5afef56d42f30eb4804e9e8dd0a213b61f56c (diff) | |
download | jQuery.equalHeights-bf409366fe03b983188676d973fef900057af35e.zip jQuery.equalHeights-bf409366fe03b983188676d973fef900057af35e.tar.gz jQuery.equalHeights-bf409366fe03b983188676d973fef900057af35e.tar.bz2 |
Add "watch" option
With `option.watch` being `true` equalHeights is reexecuted when the window resizes
-rw-r--r-- | jquery.equalheights.js | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/jquery.equalheights.js b/jquery.equalheights.js index 94f0c9a..561da88 100644 --- a/jquery.equalheights.js +++ b/jquery.equalheights.js @@ -9,6 +9,15 @@ * @version 1.5.1 */ (function($) { + + var watched = []; + $(window).on("resize", function () { + for (var i = 0, l = watched.length; i < l; i++) { + if (watched[i]) { + $(watched[i]).css("height", "auto").equalHeights() + } + } + }) $.fn.equalHeights = function(options) { var maxHeight = 0, @@ -22,7 +31,7 @@ $this.each(equalHeightsFn); - if(options.wait) { + if (options.wait) { var loop = setInterval(function() { if(maxHeight > 0) { clearInterval(loop); @@ -30,6 +39,8 @@ } $this.each(equalHeightsFn); }, 100); + } else if (options.watch) { + watched.push(this) } else { return $this.css('height', maxHeight); } |