X-Git-Url: http://git.asbjorn.it/?a=blobdiff_plain;f=src%2Foffset.js;h=18261bb570c70bbc43c584dac7c7926ca799d2cf;hb=735a949a0649f0299e8e4d87b259290970a68ddf;hp=2040c9d83ac9d5db4f15159cc980fbab5c2506fd;hpb=3e0cc815043c2425819743e907a0ce263a7ce164;p=jquery.git diff --git a/src/offset.js b/src/offset.js index 2040c9d..18261bb 100644 --- a/src/offset.js +++ b/src/offset.js @@ -30,7 +30,7 @@ if ( "getBoundingClientRect" in document.documentElement ) { // Make sure we're not dealing with a disconnected DOM node if ( !box || !jQuery.contains( docElem, elem ) ) { - return box || { top: 0, left: 0 }; + return box ? { top: box.top, left: box.left } : { top: 0, left: 0 }; } var body = doc.body, @@ -181,10 +181,10 @@ jQuery.offset = { curOffset = curElem.offset(), curCSSTop = jQuery.css( elem, "top" ), curCSSLeft = jQuery.css( elem, "left" ), - calculatePosition = (position === "absolute" && jQuery.inArray('auto', [curCSSTop, curCSSLeft]) > -1), + calculatePosition = ((position === "absolute" || position === "fixed") && jQuery.inArray('auto', [curCSSTop, curCSSLeft]) > -1), props = {}, curPosition = {}, curTop, curLeft; - // need to be able to calculate position if either top or left is auto and position is absolute + // need to be able to calculate position if either top or left is auto and position is either absolute or fixed if ( calculatePosition ) { curPosition = curElem.position(); } @@ -275,7 +275,7 @@ jQuery.each( ["Left", "Top"], function( i, name ) { if ( win ) { win.scrollTo( !i ? val : jQuery(win).scrollLeft(), - i ? val : jQuery(win).scrollTop() + i ? val : jQuery(win).scrollTop() ); } else {