aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAriel Flesler <aflesler@gmail.com>2008-05-14 18:06:59 +0000
committerAriel Flesler <aflesler@gmail.com>2008-05-14 18:06:59 +0000
commit831625c43e85a010064cac18b14ea49f1531c315 (patch)
treeab6058e39129a25ad5594e0865cb60daf3447e5d
parentac324c97e319c8a107036e7ce98dff6e5f78a8ba (diff)
downloadjquery-831625c43e85a010064cac18b14ea49f1531c315.tar.gz
jquery-831625c43e85a010064cac18b14ea49f1531c315.zip
jquery offset: reducing more the code size.
-rw-r--r--src/offset.js18
1 files changed, 10 insertions, 8 deletions
diff --git a/src/offset.js b/src/offset.js
index 1add61c9d..a35fed561 100644
--- a/src/offset.js
+++ b/src/offset.js
@@ -140,7 +140,9 @@ jQuery.fn.extend({
// Create scrollLeft and scrollTop methods
jQuery.each( ['Left', 'Top'], function(i, name) {
- jQuery.fn[ 'scroll' + name ] = function(val) {
+ var method = 'scroll' + name;
+
+ jQuery.fn[ method ] = function(val) {
if (!this[0]) return;
return val != undefined ?
@@ -149,17 +151,17 @@ jQuery.each( ['Left', 'Top'], function(i, name) {
this.each(function() {
this == window || this == document ?
window.scrollTo(
- name == 'Left' ? val : jQuery(window)[ 'scrollLeft' ](),
- name == 'Top' ? val : jQuery(window)[ 'scrollTop' ]()
+ !i ? val : jQuery(window).scrollLeft(),
+ i ? val : jQuery(window).scrollTop()
) :
- this[ 'scroll' + name ] = val;
+ this[ method ] = val;
}) :
// Return the scroll offset
this[0] == window || this[0] == document ?
- self[ (name == 'Left' ? 'pageXOffset' : 'pageYOffset') ] ||
- jQuery.boxModel && document.documentElement[ 'scroll' + name ] ||
- document.body[ 'scroll' + name ] :
- this[0][ 'scroll' + name ];
+ self[ i ? 'pageYOffset' : 'pageXOffset' ] ||
+ jQuery.boxModel && document.documentElement[ method ] ||
+ document.body[ method ] :
+ this[0][ method ];
};
});