MCPcopy Create free account
hub / github.com/TruthHun/BookStack / adjustCSS

Function adjustCSS

static/wangEditor/js/lib/jquery-2.2.1.js:4182–4238  ·  view source on GitHub ↗
( elem, prop, valueParts, tween )

Source from the content-addressed store, hash-verified

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

Callers 1

jquery-2.2.1.jsFile · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected