Merge branch 'bug_7931' of https://github.com/Xavi-/jquery into Xavi--bug_7931

Conflicts:
	src/offset.js
This commit is contained in:
John Resig 2011-04-12 16:13:56 -04:00
commit f1d75edec7
2 changed files with 31 additions and 21 deletions

View file

@ -261,29 +261,16 @@ jQuery.fn.extend({
jQuery.each( ["Left", "Top"], function( i, name ) {
var method = "scroll" + name;
jQuery.fn[ method ] = function(val) {
var elem = this[0], win;
jQuery.fn[ method ] = function( val ) {
var elem, win;
if ( !elem ) {
return null;
}
if ( val === undefined ) {
elem = this[ 0 ];
if ( val !== undefined ) {
// Set the scroll offset
return this.each(function() {
win = getWindow( this );
if ( !elem ) {
return null;
}
if ( win ) {
win.scrollTo(
!i ? val : jQuery(win).scrollLeft(),
i ? val : jQuery(win).scrollTop()
);
} else {
this[ method ] = val;
}
});
} else {
win = getWindow( elem );
// Return the scroll offset
@ -292,6 +279,21 @@ jQuery.each( ["Left", "Top"], function( i, name ) {
win.document.body[ method ] :
elem[ method ];
}
// Set the scroll offset
return this.each(function() {
win = getWindow( this );
if ( win ) {
win.scrollTo(
!i ? val : jQuery( win ).scrollLeft(),
i ? val : jQuery( win ).scrollTop()
);
} else {
this[ method ] = val;
}
});
};
});