Permalink
Browse files

Work around strange bug in IE9 where it sometimes reports the getBoun…

…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...
1 parent 43fc3ab commit fbc9bcf540bd5b04ccddee2222c878d4af0730b1 Jason Johnston committed Jun 27, 2011
Showing with 7 additions and 3 deletions.
  1. +7 −3 sources/BoundsInfo.js
View
@@ -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
};
},

0 comments on commit fbc9bcf

Please sign in to comment.