Sam152 / Javascript-Equal-Height-Responsive-Rows

A simple jQuery plugin to keep elements the same height, supporting resizing and responsive layouts.
183 stars 50 forks source link

Causes scrolling slowness in IE 8 #6

Open sinak opened 10 years ago

sinak commented 10 years ago

I know nobody wants to have to support IE 8, but using the .responsiveEqualHeightGrid method causes window scrolling to become unreasonably jerky.

sinak commented 10 years ago

It looks like syncHeights is being called continually, making IE 8 bug out.

sinak commented 10 years ago

Okay, so the problem is pretty well documented on Stack Overflow here.

My solution was to change $.fn.responsiveEqualHeightGrid to this:

$.fn.responsiveEqualHeightGrid = function() {
    var _this = this;

    function syncHeights() {
        var cols = _this.detectGridColumns();
        _this.equalHeightGrid(cols);
        setTimeout(resizeListener,100);
      }

    var resizeListener = function(){
      $(window).one('resize load', syncHeights);
    }
    resizeListener();

    syncHeights();
    return this;
  };

})(jQuery);

I'll submit a pull request, though you might want to refactor my code if you don't like this particular solution.