nexus site path corrected
[portal.git] / ecomp-portal-FE / client / bower_components / jquery / src / effects / Tween.js
1 define( [
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;
16                 this.easing = easing || jQuery.easing._default;
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
62                         // Use a property on the element directly when it is not a DOM element,
63                         // or when there is no matching style property that exists.
64                         if ( tween.elem.nodeType !== 1 ||
65                                 tween.elem[ tween.prop ] != null && tween.elem.style[ tween.prop ] == null ) {
66                                 return tween.elem[ tween.prop ];
67                         }
68
69                         // Passing an empty string as a 3rd parameter to .css will automatically
70                         // attempt a parseFloat and fallback to a string if the parse fails.
71                         // Simple values such as "10px" are parsed to Float;
72                         // complex values such as "rotate(1rad)" are returned as-is.
73                         result = jQuery.css( tween.elem, tween.prop, "" );
74
75                         // Empty strings, null, undefined and "auto" are converted to 0.
76                         return !result || result === "auto" ? 0 : result;
77                 },
78                 set: function( tween ) {
79
80                         // Use step hook for back compat.
81                         // Use cssHook if its there.
82                         // Use .style if available and use plain properties where available.
83                         if ( jQuery.fx.step[ tween.prop ] ) {
84                                 jQuery.fx.step[ tween.prop ]( tween );
85                         } else if ( tween.elem.nodeType === 1 &&
86                                 ( tween.elem.style[ jQuery.cssProps[ tween.prop ] ] != null ||
87                                         jQuery.cssHooks[ tween.prop ] ) ) {
88                                 jQuery.style( tween.elem, tween.prop, tween.now + tween.unit );
89                         } else {
90                                 tween.elem[ tween.prop ] = tween.now;
91                         }
92                 }
93         }
94 };
95
96 // Support: IE9
97 // Panic based approach to setting things on disconnected nodes
98 Tween.propHooks.scrollTop = Tween.propHooks.scrollLeft = {
99         set: function( tween ) {
100                 if ( tween.elem.nodeType && tween.elem.parentNode ) {
101                         tween.elem[ tween.prop ] = tween.now;
102                 }
103         }
104 };
105
106 jQuery.easing = {
107         linear: function( p ) {
108                 return p;
109         },
110         swing: function( p ) {
111                 return 0.5 - Math.cos( p * Math.PI ) / 2;
112         },
113         _default: "swing"
114 };
115
116 jQuery.fx = Tween.prototype.init;
117
118 // Back Compat <1.8 extension point
119 jQuery.fx.step = {};
120
121 } );