corrade-http-templates – Blame information for rev 61

Subversion Repositories:
Rev:
Rev Author Line No. Line
61 office 1 define( [
2 "../core",
3 "../var/rcssNum"
4 ], function( jQuery, rcssNum ) {
5  
6 "use strict";
7  
8 function adjustCSS( elem, prop, valueParts, tween ) {
9 var adjusted, scale,
10 maxIterations = 20,
11 currentValue = tween ?
12 function() {
13 return tween.cur();
14 } :
15 function() {
16 return jQuery.css( elem, prop, "" );
17 },
18 initial = currentValue(),
19 unit = valueParts && valueParts[ 3 ] || ( jQuery.cssNumber[ prop ] ? "" : "px" ),
20  
21 // Starting value computation is required for potential unit mismatches
22 initialInUnit = ( jQuery.cssNumber[ prop ] || unit !== "px" && +initial ) &&
23 rcssNum.exec( jQuery.css( elem, prop ) );
24  
25 if ( initialInUnit && initialInUnit[ 3 ] !== unit ) {
26  
27 // Support: Firefox <=54
28 // Halve the iteration target value to prevent interference from CSS upper bounds (gh-2144)
29 initial = initial / 2;
30  
31 // Trust units reported by jQuery.css
32 unit = unit || initialInUnit[ 3 ];
33  
34 // Iteratively approximate from a nonzero starting point
35 initialInUnit = +initial || 1;
36  
37 while ( maxIterations-- ) {
38  
39 // Evaluate and update our best guess (doubling guesses that zero out).
40 // Finish if the scale equals or crosses 1 (making the old*new product non-positive).
41 jQuery.style( elem, prop, initialInUnit + unit );
42 if ( ( 1 - scale ) * ( 1 - ( scale = currentValue() / initial || 0.5 ) ) <= 0 ) {
43 maxIterations = 0;
44 }
45 initialInUnit = initialInUnit / scale;
46  
47 }
48  
49 initialInUnit = initialInUnit * 2;
50 jQuery.style( elem, prop, initialInUnit + unit );
51  
52 // Make sure we update the tween properties later on
53 valueParts = valueParts || [];
54 }
55  
56 if ( valueParts ) {
57 initialInUnit = +initialInUnit || +initial || 0;
58  
59 // Apply relative offset (+=/-=) if specified
60 adjusted = valueParts[ 1 ] ?
61 initialInUnit + ( valueParts[ 1 ] + 1 ) * valueParts[ 2 ] :
62 +valueParts[ 2 ];
63 if ( tween ) {
64 tween.unit = unit;
65 tween.start = initialInUnit;
66 tween.end = adjusted;
67 }
68 }
69 return adjusted;
70 }
71  
72 return adjustCSS;
73 } );