Ticket #3508 (closed bug: fixed)
Problem with IE and offset/getBoundingClientRect
|Reported by:||jeffkretz||Owned by:||brandon|
|Keywords:||offset||Cc:||brandon, paul, jeffkretz|
After plumbing for quite a while, I've finally isolated what I believe is the source of an offset problem with IE, and I think it is related to a bug in the getBoundingClientRect function as applies to the documentElement.
Please see test case at http://test1.scorpiondesign.com/LocalTest2.htm.
You'll notice in IE6/7 when you scroll the window down and then drag, the position "jumps" the amount of the scroll bar.
Now watch the counters displaying information about it.
The helper is the <table> element. It's offset parent is the <html> element.
In FF3 and Opera you'll see the parent's offset is calculated correctly. You'll also notice that the document.documentElement.getBoundingRect() function returns a negative value, which is handled by adding in the document.scrollTop.
In IE6 and IE7, the parent's offset is calculated INCORRECTLY, and the document.documentElement.getBoundingRect() returns the top position of the HTML element (rather than the viewport), so when adding in the scrollTop, you get a wildly wrong offset top.
FF2, Chrome and Safari do not implement getBoundingRect, but the alternative calculation comes out correctly.
I wasn't sure the best approach here -- should the offset function do a MSIE detection and adjust the getBoundingClientRect values for the HTML element?