summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorliabru <liabru@brm.io>2014-09-10 21:21:21 +0100
committerliabru <liabru@brm.io>2014-09-10 21:21:21 +0100
commitfdc8f7ab7e37343c0d62e4e3d58912649e39add8 (patch)
tree97aab71f77345845b517258fdb0f4c454f68ab53
parentf72ab91b0d7d3531aa90443a827529626d778a98 (diff)
downloadjquery-match-height-fdc8f7ab7e37343c0d62e4e3d58912649e39add8.zip
jquery-match-height-fdc8f7ab7e37343c0d62e4e3d58912649e39add8.tar.gz
jquery-match-height-fdc8f7ab7e37343c0d62e4e3d58912649e39add8.tar.bz2
fixed throttling issue
-rw-r--r--jquery.matchHeight.js28
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