diff options
author | liabru <liabru@brm.io> | 2014-09-10 21:21:21 +0100 |
---|---|---|
committer | liabru <liabru@brm.io> | 2014-09-10 21:21:21 +0100 |
commit | fdc8f7ab7e37343c0d62e4e3d58912649e39add8 (patch) | |
tree | 97aab71f77345845b517258fdb0f4c454f68ab53 | |
parent | f72ab91b0d7d3531aa90443a827529626d778a98 (diff) | |
download | jquery-match-height-fdc8f7ab7e37343c0d62e4e3d58912649e39add8.zip jquery-match-height-fdc8f7ab7e37343c0d62e4e3d58912649e39add8.tar.gz jquery-match-height-fdc8f7ab7e37343c0d62e4e3d58912649e39add8.tar.bz2 |
fixed throttling issue
-rw-r--r-- | jquery.matchHeight.js | 28 |
1 files changed, 19 insertions, 9 deletions
diff --git a/jquery.matchHeight.js b/jquery.matchHeight.js index 8692ea1..39ce311 100644 --- a/jquery.matchHeight.js +++ b/jquery.matchHeight.js @@ -239,7 +239,13 @@ * updates matchHeight on all current groups with their correct options */ - $.fn.matchHeight._update = function(event) { + var _update = function() { + $.each($.fn.matchHeight._groups, function() { + $.fn.matchHeight._apply(this.elements, this.byRow); + }); + }; + + $.fn.matchHeight._update = function(throttle, event) { // prevent update if fired from a resize event // where the viewport width hasn't actually changed // fixes an event looping bug in IE8 @@ -251,15 +257,12 @@ } // throttle updates - if (_updateTimeout === -1) { + if (!throttle) { + _update(); + } else if (_updateTimeout === -1) { _updateTimeout = setTimeout(function() { - - $.each($.fn.matchHeight._groups, function() { - $.fn.matchHeight._apply(this.elements, this.byRow); - }); - + _update(); _updateTimeout = -1; - }, $.fn.matchHeight._throttle); } }; @@ -272,6 +275,13 @@ $($.fn.matchHeight._applyDataApi); // update heights on load and resize events - $(window).bind('load resize orientationchange', $.fn.matchHeight._update); + $(window).bind('load', function(event) { + $.fn.matchHeight._update(); + }); + + // throttled update heights on resize events + $(window).bind('resize orientationchange', function(event) { + $.fn.matchHeight._update(true, event); + }); })(jQuery);
\ No newline at end of file |