diff options
author | Matt Banks <mjbanks@gmail.com> | 2013-03-07 08:51:01 -0500 |
---|---|---|
committer | Matt Banks <mjbanks@gmail.com> | 2013-03-07 08:51:01 -0500 |
commit | 01fd250a3f64418bc89fc3aab5774bc60128bac8 (patch) | |
tree | 8971abe9ddb3706670ed2ecb041d7f153342cfef | |
parent | 5dccc25b37ac41e3830f9bd5e6c1489850133411 (diff) | |
download | jQuery.equalHeights-01fd250a3f64418bc89fc3aab5774bc60128bac8.zip jQuery.equalHeights-01fd250a3f64418bc89fc3aab5774bc60128bac8.tar.gz jQuery.equalHeights-01fd250a3f64418bc89fc3aab5774bc60128bac8.tar.bz2 |
calculate height with innerHeight to include paddingv1.2
-rw-r--r-- | README.md | 13 | ||||
-rw-r--r-- | jquery.equalheights.js | 13 | ||||
-rw-r--r-- | jquery.equalheights.min.js | 4 |
3 files changed, 18 insertions, 12 deletions
@@ -1,8 +1,8 @@ # jQuery Simple Equal Heights -Version 1.1 +Version 1.2 -## Summary +## Summary Simple jQuery plugin to equalize heights of multiple elements on a page. @@ -14,7 +14,7 @@ Matt Banks ( [@mattbanks](http://twitter.com/mattbanks) / [kernelcreativemedia.c Include `jquery.equalheights.min.js` after calling jQuery in the footer. Alternatively, include in your `plugins.js` file if using [HTML5 Boilerplate](http://html5boilerplate.com). - $('.yourelements').equalHeights(); + $('.yourelements').equalHeights(); Select whatever elements need equal height. @@ -32,6 +32,11 @@ See `example.html` in examples folder. ### Changelog +#### Version 1.2 + +* properly cache `$(this)` since it's called twice in the main function +* calculate height by `innerheight()` instead of `height()` to include any padding + #### Version 1.1 * cleaned up function call @@ -39,4 +44,4 @@ See `example.html` in examples folder. #### Version 1.0 -* initial version
\ No newline at end of file +* initial version diff --git a/jquery.equalheights.js b/jquery.equalheights.js index 5fdd692..05b19dc 100644 --- a/jquery.equalheights.js +++ b/jquery.equalheights.js @@ -6,20 +6,21 @@ * Uses the same license as jQuery, see: * http://docs.jquery.com/License * - * @version 1.1 + * @version 1.2 */ (function($) { $.fn.equalHeights = function() { - var maxHeight = 0; + var maxHeight = 0, + $this = $(this); - $(this).each( function() { - var height = $(this).height(); + $this.each( function() { + var height = $(this).innerHeight(); if ( height > maxHeight ) { maxHeight = height; } }); - $(this).height(maxHeight); + $this.height(maxHeight); }; -})(jQuery);
\ No newline at end of file +})(jQuery); diff --git a/jquery.equalheights.min.js b/jquery.equalheights.min.js index 2e9e2cd..5bbdcd0 100644 --- a/jquery.equalheights.min.js +++ b/jquery.equalheights.min.js @@ -6,6 +6,6 @@ * Uses the same license as jQuery, see: * http://docs.jquery.com/License * - * @version 1.1 + * @version 1.2 */ -(function(a){a.fn.equalHeights=function(){var b=0;a(this).each(function(){var c=a(this).height();if(c>b){b=c}});a(this).height(b)}})(jQuery);
\ No newline at end of file +(function(a){a.fn.equalHeights=function(){var b=0,c=a(this);c.each(function(){var c=a(this).innerHeight();c>b&&(b=c)}),c.height(b)}})(jQuery); |