git.asbjorn.biz
/
jquery.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (from parent 1:
ac324c9
)
jquery offset: reducing more the code size.
author
Ariel Flesler
<aflesler@gmail.com>
Wed, 14 May 2008 18:06:59 +0000
(18:06 +0000)
committer
Ariel Flesler
<aflesler@gmail.com>
Wed, 14 May 2008 18:06:59 +0000
(18:06 +0000)
src/offset.js
patch
|
blob
|
history
diff --git
a/src/offset.js
b/src/offset.js
index
1add61c
..
a35fed5
100644
(file)
--- 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) {
// 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 ?
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(
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 ?
}) :
// 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 ];
};
});
};
});