MCPcopy Create free account
hub / github.com/OpenIntroStat/ims / adjustCSS

Function adjustCSS

libs/jquery-3.5.1/jquery-2.2.4.js:4187–4243  ·  view source on GitHub ↗
( elem, prop, valueParts, tween )

Source from the content-addressed store, hash-verified

4185
4186
4187function adjustCSS( elem, prop, valueParts, tween ) {
4188 var adjusted,
4189 scale = 1,
4190 maxIterations = 20,
4191 currentValue = tween ?
4192 function() { return tween.cur(); } :
4193 function() { return jQuery.css( elem, prop, "" ); },
4194 initial = currentValue(),
4195 unit = valueParts && valueParts[ 3 ] || ( jQuery.cssNumber[ prop ] ? "" : "px" ),
4196
4197 // Starting value computation is required for potential unit mismatches
4198 initialInUnit = ( jQuery.cssNumber[ prop ] || unit !== "px" && +initial ) &&
4199 rcssNum.exec( jQuery.css( elem, prop ) );
4200
4201 if ( initialInUnit && initialInUnit[ 3 ] !== unit ) {
4202
4203 // Trust units reported by jQuery.css
4204 unit = unit || initialInUnit[ 3 ];
4205
4206 // Make sure we update the tween properties later on
4207 valueParts = valueParts || [];
4208
4209 // Iteratively approximate from a nonzero starting point
4210 initialInUnit = +initial || 1;
4211
4212 do {
4213
4214 // If previous iteration zeroed out, double until we get *something*.
4215 // Use string for doubling so we don't accidentally see scale as unchanged below
4216 scale = scale || ".5";
4217
4218 // Adjust and apply
4219 initialInUnit = initialInUnit / scale;
4220 jQuery.style( elem, prop, initialInUnit + unit );
4221
4222 // Update scale, tolerating zero or NaN from tween.cur()
4223 // Break the loop if scale is unchanged or perfect, or if we've just had enough.
4224 } while (
4225 scale !== ( scale = currentValue() / initial ) && scale !== 1 && --maxIterations
4226 );
4227 }
4228
4229 if ( valueParts ) {
4230 initialInUnit = +initialInUnit || +initial || 0;
4231
4232 // Apply relative offset (+=/-=) if specified
4233 adjusted = valueParts[ 1 ] ?
4234 initialInUnit + ( valueParts[ 1 ] + 1 ) * valueParts[ 2 ] :
4235 +valueParts[ 2 ];
4236 if ( tween ) {
4237 tween.unit = unit;
4238 tween.start = initialInUnit;
4239 tween.end = adjusted;
4240 }
4241 }
4242 return adjusted;
4243}
4244var rcheckableType = ( /^(?:checkbox|radio)$/i );

Callers 1

jquery-2.2.4.jsFile · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected