scratch – Blame information for rev 125

Subversion Repositories:
Rev:
Rev Author Line No. Line
125 office 1 define([
58 office 2 "../core",
3 "../css"
4 ], function( jQuery ) {
5  
6 function Tween( elem, options, prop, end, easing ) {
7 return new Tween.prototype.init( elem, options, prop, end, easing );
8 }
9 jQuery.Tween = Tween;
10  
11 Tween.prototype = {
12 constructor: Tween,
13 init: function( elem, options, prop, end, easing, unit ) {
14 this.elem = elem;
15 this.prop = prop;
125 office 16 this.easing = easing || "swing";
58 office 17 this.options = options;
18 this.start = this.now = this.cur();
19 this.end = end;
20 this.unit = unit || ( jQuery.cssNumber[ prop ] ? "" : "px" );
21 },
22 cur: function() {
23 var hooks = Tween.propHooks[ this.prop ];
24  
25 return hooks && hooks.get ?
26 hooks.get( this ) :
27 Tween.propHooks._default.get( this );
28 },
29 run: function( percent ) {
30 var eased,
31 hooks = Tween.propHooks[ this.prop ];
32  
33 if ( this.options.duration ) {
34 this.pos = eased = jQuery.easing[ this.easing ](
35 percent, this.options.duration * percent, 0, 1, this.options.duration
36 );
37 } else {
38 this.pos = eased = percent;
39 }
40 this.now = ( this.end - this.start ) * eased + this.start;
41  
42 if ( this.options.step ) {
43 this.options.step.call( this.elem, this.now, this );
44 }
45  
46 if ( hooks && hooks.set ) {
47 hooks.set( this );
48 } else {
49 Tween.propHooks._default.set( this );
50 }
51 return this;
52 }
53 };
54  
55 Tween.prototype.init.prototype = Tween.prototype;
56  
57 Tween.propHooks = {
58 _default: {
59 get: function( tween ) {
60 var result;
61  
125 office 62 if ( tween.elem[ tween.prop ] != null &&
63 (!tween.elem.style || tween.elem.style[ tween.prop ] == null) ) {
58 office 64 return tween.elem[ tween.prop ];
65 }
66  
67 // Passing an empty string as a 3rd parameter to .css will automatically
68 // attempt a parseFloat and fallback to a string if the parse fails.
69 // Simple values such as "10px" are parsed to Float;
70 // complex values such as "rotate(1rad)" are returned as-is.
71 result = jQuery.css( tween.elem, tween.prop, "" );
72 // Empty strings, null, undefined and "auto" are converted to 0.
73 return !result || result === "auto" ? 0 : result;
74 },
75 set: function( tween ) {
76 // Use step hook for back compat.
77 // Use cssHook if its there.
78 // Use .style if available and use plain properties where available.
79 if ( jQuery.fx.step[ tween.prop ] ) {
80 jQuery.fx.step[ tween.prop ]( tween );
125 office 81 } else if ( tween.elem.style && ( tween.elem.style[ jQuery.cssProps[ tween.prop ] ] != null || jQuery.cssHooks[ tween.prop ] ) ) {
58 office 82 jQuery.style( tween.elem, tween.prop, tween.now + tween.unit );
83 } else {
84 tween.elem[ tween.prop ] = tween.now;
85 }
86 }
87 }
88 };
89  
125 office 90 // Support: IE9
58 office 91 // Panic based approach to setting things on disconnected nodes
92 Tween.propHooks.scrollTop = Tween.propHooks.scrollLeft = {
93 set: function( tween ) {
94 if ( tween.elem.nodeType && tween.elem.parentNode ) {
95 tween.elem[ tween.prop ] = tween.now;
96 }
97 }
98 };
99  
100 jQuery.easing = {
101 linear: function( p ) {
102 return p;
103 },
104 swing: function( p ) {
105 return 0.5 - Math.cos( p * Math.PI ) / 2;
125 office 106 }
58 office 107 };
108  
109 jQuery.fx = Tween.prototype.init;
110  
125 office 111 // Back Compat <1.8 extension point
58 office 112 <1.8 extension pointjQuery.fx.step = {};
113  
125 office 114 <1.8 extension point});