aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorXavi <xavi.rmz@gmail.com>2011-01-09 20:51:20 -0500
committerXavi <xavi.rmz@gmail.com>2011-01-09 20:51:20 -0500
commitb78e3fc39f96d63a60ea66e3d066815626e633d8 (patch)
treed1ee7e6626ec499f4975d9b95c488b392bb8778c /src
parentbed64e65cc658409961a7127b715643390919e6c (diff)
downloadjquery-b78e3fc39f96d63a60ea66e3d066815626e633d8.tar.gz
jquery-b78e3fc39f96d63a60ea66e3d066815626e633d8.zip
Bug 7931; Inverted logic in scrollTop/Left (i.e. made
Diffstat (limited to 'src')
-rw-r--r--src/offset.js50
1 files changed, 25 insertions, 25 deletions
diff --git a/src/offset.js b/src/offset.js
index 02f067ebb..660efa234 100644
--- a/src/offset.js
+++ b/src/offset.js
@@ -263,34 +263,34 @@ jQuery.each( ["Left", "Top"], function( i, name ) {
jQuery.fn[ method ] = function(val) {
var elem, win;
- if ( val !== undefined ) {
- // 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;
- }
- });
- }
+ if(val === undefined) {
+ elem = this[0];
+ if( !elem ) {
+ return null;
+ }
- elem = this[0];
- if( !elem ) {
- return null;
+ win = getWindow( elem );
+ // Return the scroll offset
+ return win ? ("pageXOffset" in win) ? win[ i ? "pageYOffset" : "pageXOffset" ] :
+ jQuery.support.boxModel && win.document.documentElement[ method ] ||
+ win.document.body[ method ] :
+ elem[ method ];
}
- win = getWindow( elem );
- // Return the scroll offset
- return win ? ("pageXOffset" in win) ? win[ i ? "pageYOffset" : "pageXOffset" ] :
- jQuery.support.boxModel && win.document.documentElement[ method ] ||
- 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;
+ }
+ });
};
});