jQuery 1.5.1 animate 방법 원본 읽 기

 
/*7536-7646*/
animate: function( prop, speed, easing, callback ) {
if ( jQuery.isEmptyObject( prop ) ) {
return this.each( optall.complete );
}
//#7864 this.options.complete.call( this.elem ) , $(‘selector').animate({prop1},speed1).animate({prop2},speed2) ;
return this[ optall.queue === false ? "each" : "queue" ](function() {
// XXX 'this' does not always have a nodeName when running the
// test suite
var opt = jQuery.extend({}, optall), p,
isElement = this.nodeType === 1,
hidden = isElement && jQuery(this).is(":hidden"),
self = this;
// prop,prop plainObj, {key1:value1,key2:value2};
for ( p in prop ) {
// , magrin-top marginTop; cameCase ;
var name = jQuery.camelCase( p );
//fix ; camelcase ;
if ( p !== name ) {
prop[ name ] = prop[ p ];
delete prop[ p ];
p = name;
}
// $(..).show||$(..).hide; hidden, hide, callbacks ;
if ( prop[p] === "hide" && hidden || prop[p] === "show" && !hidden ) {
return opt.complete.call(this);
}
// prop[key]==(height||width) dom ; ;
if ( isElement && ( p === "height" || p === "width" ) ) {
// Make sure that nothing sneaks out
// Record all 3 overflow attributes because IE does not
// change the overflow attribute when overflowX and
// overflowY are set to the same value
opt.overflow = [ this.style.overflow, this.style.overflowX, this.style.overflowY ];

// Set display property to inline-block for height/width
// animations on inline elements that are having width/height
// animated
if ( jQuery.css( this, "display" ) === "inline" &&
jQuery.css( this, "float" ) === "none" ) {
if ( !jQuery.support.inlineBlockNeedsLayout ) {
this.style.display = "inline-block";

} else {
var display = defaultDisplay(this.nodeName);

// inline-level elements accept inline-block;
// block-level elements need to be inline with layout
if ( display === "inline" ) {
this.style.display = "inline-block";

} else {
this.style.display = "inline";
this.style.zoom = 1;
}
}
}
}
// prop[key] ; prop[p][0];
if ( jQuery.isArray( prop[p] ) ) {
// Create (if needed) and add to specialEasing
(opt.specialEasing = opt.specialEasing || {})[p] = prop[p][1];
prop[p] = prop[p][0];
}
}

if ( opt.overflow != null ) {
// overflow , hidden;
this.style.overflow = "hidden";
}
// , prop;
opt.curAnim = jQuery.extend({}, prop);
// , prop[key] ;
jQuery.each( prop, function( name, val ) {
// Fx ; ; self ;opt ;
var e = new jQuery.fx( self, opt, name );
// show||hide prop==fxAttrs( show||hide )
if ( rfxtypes.test(val) ) {
e[ val === "toggle" ? hidden ? "show" : "hide" : val ]( prop );
} else {
var parts = rfxnum.exec(val),
//start , style, css , ==null,undefiend,auto,0 0;
start = e.cur();
if ( parts ) {
//end , :{left:-=66px}, end=66;
var end = parseFloat( parts[2] ),
// , px,%; , z-index, , px;
unit = parts[3] || ( jQuery.cssNumber[ name ] ? "" : "px" );
// We need to compute starting value
// px, %,em ;
if ( unit !== "px" ) {
// name (end || 1) + unit, end=0; 1; start = ((end || 1) / e.cur()) * start;
jQuery.style( self, name, (end || 1) + unit);
// e.cur() start = e.cur(); , jQuery.style( self, name, (end || 1) + unit) start ; end=0 ; e.cur() , 0;
start = ((end || 1) / e.cur()) * start;
jQuery.style( self, name, start + unit);
}

// If a +=/-= token was provided, we're doing a relative animation
if ( parts[1] ) {
//end ;
end = ((parts[1] === "-=" ? -1 : 1) * end) + start;
}
e.custom( start, end, unit );
// ; '';
} else {
e.custom( start, val, "" );
}
}
});

// For JS strict compliance
return true;
});
},

좋은 웹페이지 즐겨찾기