X-Git-Url: http://git.asbjorn.it/?a=blobdiff_plain;f=src%2Foffset.js;h=20805de1c7d3b94f76095e8cf2178f7983f2547f;hb=c9899a74ac7b7ddb8663f4aa074c1c05f6514e5a;hp=674338ecbf0397a75ccc44c56f4990bc33387055;hpb=15a78f8fea8679205bc734ec053ff24ebbfd31c8;p=jquery.git diff --git a/src/offset.js b/src/offset.js index 674338e..20805de 100644 --- a/src/offset.js +++ b/src/offset.js @@ -5,15 +5,15 @@ jQuery.fn.offset = function() { var left = 0, top = 0, elem = this[0], results; if ( elem ) with ( jQuery.browser ) { - var absolute = jQuery.css(elem, "position") == "absolute", - parent = elem.parentNode, - offsetParent = elem.offsetParent, - doc = elem.ownerDocument, - safari2 = safari && !absolute && parseInt(version) < 522; + var absolute = jQuery.css(elem, "position") == "absolute", + parent = elem.parentNode, + offsetParent = elem.offsetParent, + doc = elem.ownerDocument, + safari2 = safari && parseInt(version) < 522; // Use getBoundingClientRect if available if ( elem.getBoundingClientRect ) { - box = elem.getBoundingClientRect(); + var box = elem.getBoundingClientRect(); // Add the document scroll offsets add( @@ -43,7 +43,7 @@ jQuery.fn.offset = function() { // Mozilla and Safari > 2 does not include the border on offset parents // However Mozilla adds the border for table cells - if ( mozilla && /^t[d|h]$/i.test(parent.tagName) || !safari2 ) + if ( mozilla && !/^t[d|h]$/i.test(offsetParent.tagName) || safari && parseInt(version) >= 522 ) border( offsetParent ); // Safari <= 2 doubles body offsets with an absolutely positioned element or parent @@ -55,9 +55,9 @@ jQuery.fn.offset = function() { } // Get parent scroll offsets - while ( parent.tagName && /^body|html$/i.test(parent.tagName) ) { + while ( parent.tagName && !/^body|html$/i.test(parent.tagName) ) { // Work around opera inline/table scrollLeft/Top bug - if ( /^inline|table-row.*$/i.test(jQuery.css(parent, "display")) ) + if ( !/^inline|table-row.*$/i.test(jQuery.css(parent, "display")) ) // Subtract parent scroll offsets add( -parent.scrollLeft, -parent.scrollTop ); @@ -70,7 +70,7 @@ jQuery.fn.offset = function() { } // Safari doubles body offsets with an absolutely positioned element or parent - if ( safari && absolute ) + if ( safari2 && absolute ) add( -doc.body.offsetLeft, -doc.body.offsetTop ); }