Skip to content

Commit

Permalink
Fix setting only one property at a time in .offset({})
Browse files Browse the repository at this point in the history
  • Loading branch information
brandonaaron committed Mar 23, 2010
1 parent 1844f95 commit 08cf82e
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/offset.js
Expand Up @@ -157,16 +157,19 @@ jQuery.offset = {
var curElem = jQuery( elem ),
curOffset = curElem.offset(),
curTop = parseInt( jQuery.curCSS( elem, "top", true ), 10 ) || 0,
curLeft = parseInt( jQuery.curCSS( elem, "left", true ), 10 ) || 0;
curLeft = parseInt( jQuery.curCSS( elem, "left", true ), 10 ) || 0,
props = {};

if ( jQuery.isFunction( options ) ) {
options = options.call( elem, i, curOffset );
}

var props = {
top: (options.top - curOffset.top) + curTop,
left: (options.left - curOffset.left) + curLeft
};
if (options.top != null) {
props.top = (options.top - curOffset.top) + curTop;
}
if (options.left != null) {
props.left = (options.left - curOffset.left) + curLeft;
}

if ( "using" in options ) {
options.using.call( elem, props );
Expand Down

0 comments on commit 08cf82e

Please sign in to comment.