Skip to main content

Bug Tracker

Side navigation

#3508 closed bug (fixed)

Opened October 22, 2008 04:00AM UTC

Closed April 22, 2009 03:07AM UTC

Problem with IE and offset/getBoundingClientRect

Reported by: jeffkretz Owned by: brandon
Priority: undecided Milestone: 1.3
Component: dimensions Version: 1.2.6
Keywords: offset Cc: brandon, paul, jeffkretz
Blocked by: Blocking:

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

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?


Attachments (1)
  • offset.patch (1.1 KB) - added by jeffkretz October 30, 2008 10:16PM UTC.
Change History (7)

Changed October 22, 2008 12:18PM UTC by john comment:1

cc: → brandon, paul

Hmm, not sure which aspect might be causing this - any thoughts Paul or Brandon?

Changed October 27, 2008 05:46PM UTC by jeffkretz comment:2

Any feedback on this? It seems browser detection on the getBoundingRect function may be necessary.

What do you think?


Changed October 30, 2008 10:16PM UTC by jeffkretz comment:3

I hesitate to fiddle with such a core component of the system, but I've put in a browser-detection workaround which has solved the issue for me.

The patch is attached.

Can someone review this for potential inclusion?


Changed January 07, 2009 03:07AM UTC by dmethvin comment:4

cc: brandon, paulbrandon, paul, jeffkretz

Jeff, if this is still an issue can you attach the test case? The link no longer works.

Changed January 08, 2009 07:24PM UTC by jeffkretz comment:5

I've restored the test case -- the link works again.


Changed January 15, 2009 08:49PM UTC by jeffkretz comment:6

This ticket should be closed as handled, I just tested the problem with 1.3 and everything is working fine. JK

Changed April 22, 2009 03:07AM UTC by brandon comment:7

resolution: → fixed
status: newclosed