Skip to content
Permalink
Browse files

fix the long standing 2px offset issue in QuirksMode in IE

  • Loading branch information
brandonaaron committed Nov 13, 2008
1 parent 3b1cf91 commit 464535e0965d5de617a24e608a2d05393194c3fd
Showing with 4 additions and 3 deletions.
  1. +4 −3 src/offset.js
@@ -2,9 +2,10 @@ if ( document.documentElement["getBoundingClientRect"] )
jQuery.fn.offset = function() {
if ( !this[0] ) return { top: 0, left: 0 };
if ( this[0] === this[0].ownerDocument.body ) return jQuery.offset.bodyOffset( this[0] );
var box = this[0].getBoundingClientRect(), doc = this[0].ownerDocument, docElem = doc.documentElement,
top = box.top + (self.pageYOffset || jQuery.boxModel && docElem.scrollTop || doc.body.scrollTop ) - docElem.clientTop,
left = box.left + (self.pageXOffset || jQuery.boxModel && docElem.scrollLeft || doc.body.scrollLeft) - docElem.clientLeft;
var box = this[0].getBoundingClientRect(), doc = this[0].ownerDocument, body = doc.body, docElem = doc.documentElement,
clientTop = docElem.clientTop || body.clientTop || 0, clientLeft = docElem.clientLeft || body.clientLeft || 0,
top = box.top + (self.pageYOffset || jQuery.boxModel && docElem.scrollTop || body.scrollTop ) - clientTop,
left = box.left + (self.pageXOffset || jQuery.boxModel && docElem.scrollLeft || body.scrollLeft) - clientLeft;
return { top: top, left: left };
};
else

0 comments on commit 464535e

Please sign in to comment.
You can’t perform that action at this time.