summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatt Banks <mjbanks@gmail.com>2015-07-17 10:56:38 -0400
committerMatt Banks <mjbanks@gmail.com>2015-07-17 10:56:38 -0400
commit69d5afef56d42f30eb4804e9e8dd0a213b61f56c (patch)
treef815eaca5e0b4bb61ec3283ceb69dbd5d0b24756
parent23aacc7734b8881ace02f226fdfa49d12fdc20c2 (diff)
parentc539e792cd0ad16bb1c60fe25e507e1955cff197 (diff)
downloadjQuery.equalHeights-69d5afef56d42f30eb4804e9e8dd0a213b61f56c.zip
jQuery.equalHeights-69d5afef56d42f30eb4804e9e8dd0a213b61f56c.tar.gz
jQuery.equalHeights-69d5afef56d42f30eb4804e9e8dd0a213b61f56c.tar.bz2
Merge pull request #13 from DavidMoritz/patch-1
Add option "wait"
-rw-r--r--jquery.equalheights.js28
1 files changed, 20 insertions, 8 deletions
diff --git a/jquery.equalheights.js b/jquery.equalheights.js
index d05c700..94f0c9a 100644
--- a/jquery.equalheights.js
+++ b/jquery.equalheights.js
@@ -10,17 +10,29 @@
*/
(function($) {
- $.fn.equalHeights = function() {
+ $.fn.equalHeights = function(options) {
var maxHeight = 0,
- $this = $(this);
+ $this = $(this),
+ equalHeightsFn = function() {
+ var height = $(this).innerHeight();
+
+ if ( height > maxHeight ) { maxHeight = height; }
+ };
+ options = options || {};
- $this.each( function() {
- var height = $(this).innerHeight();
+ $this.each(equalHeightsFn);
- if ( height > maxHeight ) { maxHeight = height; }
- });
-
- return $this.css('height', maxHeight);
+ if(options.wait) {
+ var loop = setInterval(function() {
+ if(maxHeight > 0) {
+ clearInterval(loop);
+ return $this.css('height', maxHeight);
+ }
+ $this.each(equalHeightsFn);
+ }, 100);
+ } else {
+ return $this.css('height', maxHeight);
+ }
};
// auto-initialize plugin