mirror of
https://github.com/jquery/jquery.git
synced 2024-11-23 02:54:22 +00:00
jquery offset: reducing more the code size.
This commit is contained in:
parent
ac324c97e3
commit
831625c43e
@ -140,7 +140,9 @@ jQuery.fn.extend({
|
|||||||
|
|
||||||
// Create scrollLeft and scrollTop methods
|
// Create scrollLeft and scrollTop methods
|
||||||
jQuery.each( ['Left', 'Top'], function(i, name) {
|
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;
|
if (!this[0]) return;
|
||||||
|
|
||||||
return val != undefined ?
|
return val != undefined ?
|
||||||
@ -149,17 +151,17 @@ jQuery.each( ['Left', 'Top'], function(i, name) {
|
|||||||
this.each(function() {
|
this.each(function() {
|
||||||
this == window || this == document ?
|
this == window || this == document ?
|
||||||
window.scrollTo(
|
window.scrollTo(
|
||||||
name == 'Left' ? val : jQuery(window)[ 'scrollLeft' ](),
|
!i ? val : jQuery(window).scrollLeft(),
|
||||||
name == 'Top' ? val : jQuery(window)[ 'scrollTop' ]()
|
i ? val : jQuery(window).scrollTop()
|
||||||
) :
|
) :
|
||||||
this[ 'scroll' + name ] = val;
|
this[ method ] = val;
|
||||||
}) :
|
}) :
|
||||||
|
|
||||||
// Return the scroll offset
|
// Return the scroll offset
|
||||||
this[0] == window || this[0] == document ?
|
this[0] == window || this[0] == document ?
|
||||||
self[ (name == 'Left' ? 'pageXOffset' : 'pageYOffset') ] ||
|
self[ i ? 'pageYOffset' : 'pageXOffset' ] ||
|
||||||
jQuery.boxModel && document.documentElement[ 'scroll' + name ] ||
|
jQuery.boxModel && document.documentElement[ method ] ||
|
||||||
document.body[ 'scroll' + name ] :
|
document.body[ method ] :
|
||||||
this[0][ 'scroll' + name ];
|
this[0][ method ];
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user