Skip to content

Commit

Permalink
Work around strange bug in IE9 where it sometimes reports the getBoun…
Browse files Browse the repository at this point in the history
…dingClientRect()'s right - left or bottom - top as 1px larger than the element's actual dimensions when scrolling the page. This was causing many extraneous redraws because it thought the element's size was changing when scrolling.
  • Loading branch information
Jason Johnston committed Jun 27, 2011
1 parent 43fc3ab commit fbc9bcf
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions sources/BoundsInfo.js
Expand Up @@ -23,12 +23,16 @@ PIE.BoundsInfo.prototype = {
},

getLiveBounds: function() {
var rect = this.targetElement.getBoundingClientRect();
var el = this.targetElement,
rect = el.getBoundingClientRect(),
isIE9 = PIE.ieDocMode === 9;
return {
x: rect.left,
y: rect.top,
w: rect.right - rect.left,
h: rect.bottom - rect.top
// In some cases scrolling the page will cause IE9 to report incorrect dimensions
// in the rect returned by getBoundingClientRect, so we must query offsetWidth/Height instead
w: isIE9 ? el.offsetWidth : rect.right - rect.left,
h: isIE9 ? el.offsetHeight : rect.bottom - rect.top
};
},

Expand Down

0 comments on commit fbc9bcf

Please sign in to comment.