aboutsummaryrefslogtreecommitdiffstats
path: root/src/offset.js
diff options
context:
space:
mode:
authorJohn Resig <jeresig@gmail.com>2011-04-12 16:13:56 -0400
committerJohn Resig <jeresig@gmail.com>2011-04-12 16:13:56 -0400
commitf1d75edec70783d67f0e11459f0a2187d98cc553 (patch)
treed9e66e3d2788dd44df32ed64df8004426aa02c1d /src/offset.js
parent978c0655550ffbe32d977dbc997082e287c3a2b8 (diff)
parent135a384cf3e4cc3671de4cfcced20f294a5667a8 (diff)
downloadjquery-f1d75edec70783d67f0e11459f0a2187d98cc553.tar.gz
jquery-f1d75edec70783d67f0e11459f0a2187d98cc553.zip
Merge branch 'bug_7931' of https://github.com/Xavi-/jquery into Xavi--bug_7931
Conflicts: src/offset.js
Diffstat (limited to 'src/offset.js')
-rw-r--r--src/offset.js42
1 files changed, 22 insertions, 20 deletions
diff --git a/src/offset.js b/src/offset.js
index 95177434c..31f2503a4 100644
--- a/src/offset.js
+++ b/src/offset.js
@@ -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 ) {
- // Set the scroll offset
- return this.each(function() {
- win = getWindow( this );
+ if ( val === undefined ) {
+ elem = this[ 0 ];
- if ( win ) {
- win.scrollTo(
- !i ? val : jQuery(win).scrollLeft(),
- i ? val : jQuery(win).scrollTop()
- );
+ if ( !elem ) {
+ return null;
+ }
- } 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;
+ }
+ });
};
});