From 22b74da8c739af31d5c5164e761325d1ef939d31 Mon Sep 17 00:00:00 2001 From: liabru Date: Tue, 15 Apr 2014 12:18:55 +0100 Subject: [PATCH] fixed IE8 window resize event loop bug --- jquery.matchHeight.js | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/jquery.matchHeight.js b/jquery.matchHeight.js index 337e412..110a91d 100644 --- a/jquery.matchHeight.js +++ b/jquery.matchHeight.js @@ -121,7 +121,20 @@ $.fn.matchHeight._groups = []; - $.fn.matchHeight._update = function() { + var previousResizeWidth = -1; + + $.fn.matchHeight._update = function(event) { + + // prevent update if fired from a resize event + // where the viewport width hasn't actually changed + // fixes an event looping bug in IE8 + if (event && event.type === 'resize') { + var windowWidth = $(window).width(); + if (windowWidth === previousResizeWidth) + return; + previousResizeWidth = windowWidth; + } + $.each($.fn.matchHeight._groups, function() { $.fn.matchHeight._apply(this.elements, this.byRow); });