Fix setting only one property at a time in .offset({})

This commit is contained in:
Brandon Aaron 2010-03-22 20:05:08 -04:00
parent 1844f95c5b
commit 08cf82e88e

View file

@ -157,16 +157,19 @@ jQuery.offset = {
var curElem = jQuery( elem ), var curElem = jQuery( elem ),
curOffset = curElem.offset(), curOffset = curElem.offset(),
curTop = parseInt( jQuery.curCSS( elem, "top", true ), 10 ) || 0, 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 ) ) { if ( jQuery.isFunction( options ) ) {
options = options.call( elem, i, curOffset ); options = options.call( elem, i, curOffset );
} }
var props = { if (options.top != null) {
top: (options.top - curOffset.top) + curTop, props.top = (options.top - curOffset.top) + curTop;
left: (options.left - curOffset.left) + curLeft }
}; if (options.left != null) {
props.left = (options.left - curOffset.left) + curLeft;
}
if ( "using" in options ) { if ( "using" in options ) {
options.using.call( elem, props ); options.using.call( elem, props );