source: cows/branches/cows-vis/cows/pylons/project_templates/cows_server/+package+/public/js/yui/api/anim.js.html @ 5259

Subversion URL: http://proj.badc.rl.ac.uk/svn/ndg/cows/branches/cows-vis/cows/pylons/project_templates/cows_server/+package+/public/js/yui/api/anim.js.html@5259
Revision 5259, 66.0 KB checked in by domlowe, 11 years ago (diff)

adding yui javascript

RevLine 
[5259]1<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
2<html>
3<head>
4        <title>API: anim   anim.js  (YUI Library)</title>
5        <link rel="stylesheet" type="text/css" href="assets/api.css">
6    <script type="text/javascript" src="assets/api-js"></script>
7    <script type="text/javascript" src="assets/ac-js"></script>
8</head>
9
10<body id="yahoo-com">
11
12<div id="doc3" class="yui-t2">
13
14        <div id="hd">
15        <a href="http://developer.yahoo.com/yui/"><h1>Yahoo! UI Library</h1></a>
16        <h3>anim&nbsp; <span class="subtitle">3.0.0pr1</span></h3>
17        <p>
18        <a href="./index.html">Yahoo! UI Library</a> 
19            &gt; <a href="./module_anim.html">anim</a>
20               
21                 &gt; anim.js (source view)
22            </p>
23
24
25        </div>
26
27        <div id="bd">
28                <div id="yui-main">
29                        <div class="yui-b">
30            <form name="yui-classopts-form">
31    <span id="classopts"><input type="checkbox" name="showprivate" id="showprivate" /> <label for="showprivate">Show Private</label></span>
32    <span id="classopts"><input type="checkbox" name="showprotected" id="showprotected" /> <label for="showprotected">Show Protected</label></span>
33    <span id="classopts"><input type="checkbox" name="showdeprecated" id="showdeprecated" /> <label for="showdeprecated">Show Deprecated</label></span>
34            </form>
35
36                    <div id="srcout">
37                        <style>
38                            #doc3 #classopts { display:none; }
39                        </style>
40<div class="highlight" ><pre><span class="c">/**</span>
41<span class="c"> * Y.Animation Utility.</span>
42<span class="c"> * @module anim</span>
43<span class="c"> */</span>
44
45    <span class="c">/**</span>
46<span class="c">     * Handles animation _queueing and threading.</span>
47<span class="c">     * @class Anim</span>
48<span class="c">     * @constructor</span>
49<span class="c">     * @extends Base</span>
50<span class="c">     */</span>
51
52    <span class="k">var</span> <span class="nx">RUNNING</span> <span class="o">=</span> <span class="s1">&#39;running&#39;</span><span class="o">,</span>
53        <span class="nx">START_TIME</span> <span class="o">=</span> <span class="s1">&#39;startTime&#39;</span><span class="o">,</span>
54        <span class="nx">ELAPSED_TIME</span> <span class="o">=</span> <span class="s1">&#39;elapsedTime&#39;</span><span class="o">,</span>
55        <span class="c">/**</span>
56<span class="c">        * @event start</span>
57<span class="c">        * @description fires when an animation begins.</span>
58<span class="c">        * @param {Event} ev The start event.</span>
59<span class="c">        * @type Event.Custom</span>
60<span class="c">        */</span>
61        <span class="nx">START</span> <span class="o">=</span> <span class="s1">&#39;start&#39;</span><span class="o">,</span>
62
63        <span class="c">/**</span>
64<span class="c">        * @event tween</span>
65<span class="c">        * @description fires every frame of the animation.</span>
66<span class="c">        * @param {Event} ev The tween event.</span>
67<span class="c">        * @type Event.Custom</span>
68<span class="c">        */</span>
69        <span class="nx">TWEEN</span> <span class="o">=</span> <span class="s1">&#39;tween&#39;</span><span class="o">,</span>
70
71        <span class="c">/**</span>
72<span class="c">        * @event end</span>
73<span class="c">        * @description fires after the animation completes.</span>
74<span class="c">        * @param {Event} ev The end event.</span>
75<span class="c">        * @type Event.Custom</span>
76<span class="c">        */</span>
77        <span class="nx">END</span> <span class="o">=</span> <span class="s1">&#39;end&#39;</span><span class="o">,</span>
78        <span class="nx">NODE</span> <span class="o">=</span> <span class="s1">&#39;node&#39;</span><span class="o">,</span>
79        <span class="nx">PAUSED</span> <span class="o">=</span> <span class="s1">&#39;paused&#39;</span><span class="o">,</span>
80        <span class="nx">REVERSE</span> <span class="o">=</span> <span class="s1">&#39;reverse&#39;</span><span class="o">,</span> <span class="c">// TODO: cleanup</span>
81<span class="c"></span>        <span class="nx">ITERATION_COUNT</span> <span class="o">=</span> <span class="s1">&#39;iterationCount&#39;</span><span class="o">,</span>
82
83        <span class="nx">NUM</span> <span class="o">=</span> <span class="nb">Number</span><span class="o">;</span>
84
85    <span class="k">var</span> <span class="nx">_running</span> <span class="o">=</span> <span class="o">{},</span>
86        <span class="nx">_instances</span> <span class="o">=</span> <span class="o">{},</span>
87        <span class="nx">_timer</span><span class="o">;</span>
88
89    <span class="k">var</span> <span class="nx">_setPrivate</span> <span class="o">=</span> <span class="k">function</span><span class="o">(</span><span class="nx">anim</span><span class="o">,</span> <span class="nx">prop</span><span class="o">,</span> <span class="nx">val</span><span class="o">)</span> <span class="o">{</span>
90        <span class="k">if</span> <span class="o">(</span><span class="k">typeof</span> <span class="nx">prop</span> <span class="o">==</span> <span class="s1">&#39;string&#39;</span><span class="o">)</span> <span class="o">{</span>
91            <span class="nx">anim</span><span class="o">.</span><span class="nx">_conf</span><span class="o">.</span><span class="nx">add</span><span class="o">(</span><span class="nx">prop</span><span class="o">,</span> <span class="o">{</span> <span class="nx">value</span><span class="o">:</span> <span class="nx">val</span> <span class="o">});</span>
92        <span class="o">}</span> <span class="k">else</span> <span class="o">{</span>
93            <span class="nx">Y</span><span class="o">.</span><span class="nx">each</span><span class="o">(</span><span class="nx">prop</span><span class="o">,</span> <span class="k">function</span><span class="o">(</span><span class="nx">v</span><span class="o">,</span> <span class="nx">n</span><span class="o">)</span> <span class="o">{</span>
94                <span class="nx">_setPrivate</span><span class="o">(</span><span class="nx">anim</span><span class="o">,</span> <span class="nx">n</span><span class="o">,</span> <span class="nx">v</span><span class="o">);</span>
95            <span class="o">});</span>
96        <span class="o">}</span>
97    <span class="o">};</span>
98    <span class="nx">Y</span><span class="o">.</span><span class="nx">Anim</span> <span class="o">=</span> <span class="k">function</span><span class="o">()</span> <span class="o">{</span>
99        <span class="nx">Y</span><span class="o">.</span><span class="nx">Anim</span><span class="o">.</span><span class="nx">superclass</span><span class="o">.</span><span class="nx">constructor</span><span class="o">.</span><span class="nx">apply</span><span class="o">(</span><span class="k">this</span><span class="o">,</span> <span class="nx">arguments</span><span class="o">);</span>
100        <span class="nx">_instances</span><span class="o">[</span><span class="nx">Y</span><span class="o">.</span><span class="nx">stamp</span><span class="o">(</span><span class="k">this</span><span class="o">)]</span> <span class="o">=</span> <span class="k">this</span><span class="o">;</span>
101    <span class="o">};</span>
102
103    <span class="nx">Y</span><span class="o">.</span><span class="nx">Anim</span><span class="o">.</span><span class="nx">NAME</span> <span class="o">=</span> <span class="s1">&#39;anim&#39;</span><span class="o">;</span>
104
105    <span class="c">/**</span>
106<span class="c">     * Regex of properties that should use the default unit.</span>
107<span class="c">     *</span>
108<span class="c">     * @property RE_DEFAULT_UNIT</span>
109<span class="c">     * @static</span>
110<span class="c">     */</span>
111    <span class="nx">Y</span><span class="o">.</span><span class="nx">Anim</span><span class="o">.</span><span class="nx">RE_DEFAULT_UNIT</span> <span class="o">=</span> <span class="sr">/^width|height|top|right|bottom|left|margin.*|padding.*|border.*$/i</span><span class="o">;</span>
112
113    <span class="c">/**</span>
114<span class="c">     * The default unit to use with properties that pass the RE_DEFAULT_UNIT test.</span>
115<span class="c">     *</span>
116<span class="c">     * @property DEFAULT_UNIT</span>
117<span class="c">     * @static</span>
118<span class="c">     */</span>
119    <span class="nx">Y</span><span class="o">.</span><span class="nx">Anim</span><span class="o">.</span><span class="nx">DEFAULT_UNIT</span> <span class="o">=</span> <span class="s1">&#39;px&#39;</span><span class="o">;</span>
120
121
122    <span class="c">/**</span>
123<span class="c">     * Bucket for custom getters and setters</span>
124<span class="c">     *</span>
125<span class="c">     * @property behaviors</span>
126<span class="c">     * @static</span>
127<span class="c">     */</span>
128    <span class="nx">Y</span><span class="o">.</span><span class="nx">Anim</span><span class="o">.</span><span class="nx">behaviors</span> <span class="o">=</span> <span class="o">{</span>
129        <span class="nx">left</span><span class="o">:</span> <span class="o">{</span>
130            <span class="nx">get</span><span class="o">:</span> <span class="k">function</span><span class="o">(</span><span class="nx">anim</span><span class="o">,</span> <span class="nx">attr</span><span class="o">)</span> <span class="o">{</span>
131                <span class="k">return</span> <span class="nx">anim</span><span class="o">.</span><span class="nx">_getOffset</span><span class="o">(</span><span class="nx">attr</span><span class="o">);</span>
132            <span class="o">}</span>
133        <span class="o">}</span>
134    <span class="o">};</span>
135
136    <span class="nx">Y</span><span class="o">.</span><span class="nx">Anim</span><span class="o">.</span><span class="nx">behaviors</span><span class="o">.</span><span class="nx">top</span> <span class="o">=</span> <span class="nx">Y</span><span class="o">.</span><span class="nx">Anim</span><span class="o">.</span><span class="nx">behaviors</span><span class="o">.</span><span class="nx">left</span><span class="o">;</span>
137
138    <span class="c">/**</span>
139<span class="c">     * The default setter to use when setting object properties.</span>
140<span class="c">     *</span>
141<span class="c">     * @property DEFAULT_SETTER</span>
142<span class="c">     * @static</span>
143<span class="c">     */</span>
144    <span class="nx">Y</span><span class="o">.</span><span class="nx">Anim</span><span class="o">.</span><span class="nx">DEFAULT_SETTER</span> <span class="o">=</span> <span class="k">function</span><span class="o">(</span><span class="nx">anim</span><span class="o">,</span> <span class="nx">att</span><span class="o">,</span> <span class="nx">from</span><span class="o">,</span> <span class="nx">to</span><span class="o">,</span> <span class="nx">elapsed</span><span class="o">,</span> <span class="nx">duration</span><span class="o">,</span> <span class="nx">fn</span><span class="o">,</span> <span class="nx">unit</span><span class="o">)</span> <span class="o">{</span>
145        <span class="nx">unit</span> <span class="o">=</span> <span class="nx">unit</span> <span class="o">||</span> <span class="s1">&#39;&#39;</span><span class="o">;</span>
146        <span class="nx">anim</span><span class="o">.</span><span class="nx">_node</span><span class="o">.</span><span class="nx">setStyle</span><span class="o">(</span><span class="nx">att</span><span class="o">,</span> <span class="nx">fn</span><span class="o">(</span><span class="nx">elapsed</span><span class="o">,</span> <span class="nx">NUM</span><span class="o">(</span><span class="nx">from</span><span class="o">),</span> <span class="nx">NUM</span><span class="o">(</span><span class="nx">to</span><span class="o">)</span> <span class="o">-</span> <span class="nx">NUM</span><span class="o">(</span><span class="nx">from</span><span class="o">),</span> <span class="nx">duration</span><span class="o">)</span> <span class="o">+</span> <span class="nx">unit</span><span class="o">);</span>
147    <span class="o">};</span>
148
149    <span class="c">/**</span>
150<span class="c">     * The default getter to use when getting object properties.</span>
151<span class="c">     *</span>
152<span class="c">     * @property DEFAULT_GETTER</span>
153<span class="c">     * @static</span>
154<span class="c">     */</span>
155    <span class="nx">Y</span><span class="o">.</span><span class="nx">Anim</span><span class="o">.</span><span class="nx">DEFAULT_GETTER</span> <span class="o">=</span> <span class="k">function</span><span class="o">(</span><span class="nx">anim</span><span class="o">,</span> <span class="nx">prop</span><span class="o">)</span> <span class="o">{</span>
156        <span class="k">return</span> <span class="nx">anim</span><span class="o">.</span><span class="nx">_node</span><span class="o">.</span><span class="nx">getComputedStyle</span><span class="o">(</span><span class="nx">prop</span><span class="o">);</span>
157    <span class="o">};</span>
158
159    <span class="nx">Y</span><span class="o">.</span><span class="nx">Anim</span><span class="o">.</span><span class="nx">ATTRS</span> <span class="o">=</span> <span class="o">{</span>
160        <span class="c">/**</span>
161<span class="c">         * The object to be animated.</span>
162<span class="c">         * @attribute node</span>
163<span class="c">         * @type Node</span>
164<span class="c">         */</span>
165        <span class="nx">node</span><span class="o">:</span> <span class="o">{</span>
166            <span class="nx">set</span><span class="o">:</span> <span class="k">function</span><span class="o">(</span><span class="nx">node</span><span class="o">)</span> <span class="o">{</span>
167                <span class="nx">node</span> <span class="o">=</span> <span class="nx">Y</span><span class="o">.</span><span class="nx">Node</span><span class="o">.</span><span class="nx">get</span><span class="o">(</span><span class="nx">node</span><span class="o">);</span>
168                <span class="k">this</span><span class="o">.</span><span class="nx">_node</span> <span class="o">=</span> <span class="nx">node</span><span class="o">;</span>
169                <span class="k">if</span> <span class="o">(!</span><span class="nx">node</span><span class="o">)</span> <span class="o">{</span>
170                    <span class="nx">Y</span><span class="o">.</span><span class="nx">fail</span><span class="o">(</span><span class="s1">&#39;Y.Anim: invalid node: &#39;</span> <span class="o">+</span> <span class="nx">node</span><span class="o">);</span>
171                <span class="o">}</span>
172                <span class="k">return</span> <span class="nx">node</span><span class="o">;</span>
173            <span class="o">}</span>
174        <span class="o">},</span>
175
176        <span class="c">/**</span>
177<span class="c">         * The length of the animation.  Defaults to &quot;1&quot; (second).</span>
178<span class="c">         * @attribute duration</span>
179<span class="c">         * @type NUM</span>
180<span class="c">         */</span>
181        <span class="nx">duration</span><span class="o">:</span> <span class="o">{</span>
182            <span class="nx">value</span><span class="o">:</span> <span class="m">1</span>
183        <span class="o">},</span>
184
185        <span class="c">/**</span>
186<span class="c">         * The method that will provide values to the attribute(s) during the animation. </span>
187<span class="c">         * Defaults to &quot;Easing.easeNone&quot;.</span>
188<span class="c">         * @attribute easing</span>
189<span class="c">         * @type Function</span>
190<span class="c">         */</span>
191        <span class="nx">easing</span><span class="o">:</span> <span class="o">{</span>
192            <span class="nx">value</span><span class="o">:</span> <span class="k">function</span> <span class="o">(</span><span class="nx">t</span><span class="o">,</span> <span class="nx">b</span><span class="o">,</span> <span class="nx">c</span><span class="o">,</span> <span class="nx">d</span><span class="o">)</span> <span class="o">{</span>
193                <span class="k">return</span> <span class="nx">c</span> <span class="o">*</span> <span class="nx">t</span> <span class="sr">/ d + b; /</span><span class="o">/</span> <span class="nx">linear</span> <span class="nx">easing</span>
194            <span class="o">}</span>
195        <span class="o">},</span>
196
197        <span class="c">/**</span>
198<span class="c">         * The starting values for the animated properties. </span>
199<span class="c">         * Fields may be strings, numbers, or functions.</span>
200<span class="c">         * If a function is used, the return value becomes the from value.</span>
201<span class="c">         * If no from value is specified, the DEFAULT_GETTER will be used. </span>
202<span class="c">         * @attribute from</span>
203<span class="c">         * @type Object</span>
204<span class="c">         */</span>
205        <span class="nx">from</span><span class="o">:</span> <span class="o">{},</span>
206
207        <span class="c">/**</span>
208<span class="c">         * The ending values for the animated properties. </span>
209<span class="c">         * Fields may be strings, numbers, or functions.</span>
210<span class="c">         * @attribute to</span>
211<span class="c">         * @type Object</span>
212<span class="c">         */</span>
213        <span class="nx">to</span><span class="o">:</span> <span class="o">{},</span>
214
215        <span class="c">/**</span>
216<span class="c">         * Date stamp for the first frame of the animation.</span>
217<span class="c">         * @attribute startTime</span>
218<span class="c">         * @type Int</span>
219<span class="c">         * @default 0 </span>
220<span class="c">         * @readOnly</span>
221<span class="c">         */</span>
222        <span class="nx">startTime</span><span class="o">:</span> <span class="o">{</span>
223            <span class="nx">value</span><span class="o">:</span> <span class="m">0</span><span class="o">,</span>
224            <span class="nx">readOnly</span><span class="o">:</span> <span class="kc">true</span>
225        <span class="o">},</span>
226
227        <span class="c">/**</span>
228<span class="c">         * Current time the animation has been running.</span>
229<span class="c">         * @attribute elapsedTime</span>
230<span class="c">         * @type Int</span>
231<span class="c">         * @default 0 </span>
232<span class="c">         * @readOnly</span>
233<span class="c">         */</span>
234        <span class="nx">elapsedTime</span><span class="o">:</span> <span class="o">{</span>
235            <span class="nx">value</span><span class="o">:</span> <span class="m">0</span><span class="o">,</span>
236            <span class="nx">readOnly</span><span class="o">:</span> <span class="kc">true</span>
237        <span class="o">},</span>
238
239        <span class="c">/**</span>
240<span class="c">         * Whether or not the animation is currently running.</span>
241<span class="c">         * @attribute running </span>
242<span class="c">         * @type Boolean</span>
243<span class="c">         * @default false </span>
244<span class="c">         * @readOnly</span>
245<span class="c">         */</span>
246        <span class="nx">running</span><span class="o">:</span> <span class="o">{</span>
247            <span class="nx">get</span><span class="o">:</span> <span class="k">function</span><span class="o">()</span> <span class="o">{</span>
248                <span class="k">return</span> <span class="o">!!</span><span class="nx">_running</span><span class="o">[</span><span class="nx">Y</span><span class="o">.</span><span class="nx">stamp</span><span class="o">(</span><span class="k">this</span><span class="o">)];</span>
249            <span class="o">},</span>
250            <span class="nx">value</span><span class="o">:</span> <span class="kc">false</span><span class="o">,</span>
251            <span class="nx">readOnly</span><span class="o">:</span> <span class="kc">true</span>
252        <span class="o">},</span>
253
254        <span class="c">/**</span>
255<span class="c">         * The number of times the animation should run </span>
256<span class="c">         * @attribute iterations</span>
257<span class="c">         * @type Int</span>
258<span class="c">         * @default 1 </span>
259<span class="c">         */</span>
260        <span class="nx">iterations</span><span class="o">:</span> <span class="o">{</span>
261            <span class="nx">value</span><span class="o">:</span> <span class="m">1</span>
262        <span class="o">},</span>
263
264        <span class="c">/**</span>
265<span class="c">         * The number of iterations that have occurred.</span>
266<span class="c">         * Resets when an animation ends (reaches iteration count or stop() called). </span>
267<span class="c">         * @attribute iterationCount</span>
268<span class="c">         * @type Int</span>
269<span class="c">         * @default 0</span>
270<span class="c">         * @readOnly</span>
271<span class="c">         */</span>
272        <span class="nx">iterationCount</span><span class="o">:</span> <span class="o">{</span>
273            <span class="nx">value</span><span class="o">:</span> <span class="m">0</span><span class="o">,</span>
274            <span class="nx">readOnly</span><span class="o">:</span> <span class="kc">true</span>
275        <span class="o">},</span>
276
277        <span class="c">/**</span>
278<span class="c">         * How iterations of the animation should behave. </span>
279<span class="c">         * Possible values are &quot;normal&quot; and &quot;alternate&quot;.</span>
280<span class="c">         * Normal will repeat the animation, alternate will reverse on every other pass.</span>
281<span class="c">         *</span>
282<span class="c">         * @attribute direction</span>
283<span class="c">         * @type String</span>
284<span class="c">         * @default &quot;normal&quot;</span>
285<span class="c">         */</span>
286        <span class="nx">direction</span><span class="o">:</span> <span class="o">{</span>
287            <span class="nx">value</span><span class="o">:</span> <span class="s1">&#39;normal&#39;</span> <span class="c">// | alternate (fwd on odd, rev on even per spec)</span>
288<span class="c"></span>        <span class="o">},</span>
289
290        <span class="c">/**</span>
291<span class="c">         * Whether or not the animation is currently paused.</span>
292<span class="c">         * @attribute running </span>
293<span class="c">         * @type Boolean</span>
294<span class="c">         * @default false </span>
295<span class="c">         * @readOnly</span>
296<span class="c">         */</span>
297        <span class="nx">paused</span><span class="o">:</span> <span class="o">{</span>
298            <span class="nx">readOnly</span><span class="o">:</span> <span class="kc">true</span><span class="o">,</span>
299            <span class="nx">value</span><span class="o">:</span> <span class="kc">false</span>
300        <span class="o">},</span>
301
302        <span class="c">/**</span>
303<span class="c">         * If true, animation begins from last frame</span>
304<span class="c">         * @attribute reverse</span>
305<span class="c">         * @type Boolean</span>
306<span class="c">         * @default false </span>
307<span class="c">         */</span>
308        <span class="nx">reverse</span><span class="o">:</span> <span class="o">{</span>
309            <span class="nx">value</span><span class="o">:</span> <span class="kc">false</span>
310        <span class="o">}</span>
311
312
313    <span class="o">};</span>
314
315    <span class="c">/**</span>
316<span class="c">     * Runs all animation instances.</span>
317<span class="c">     * @method run</span>
318<span class="c">     * @static</span>
319<span class="c">     */</span>   
320    <span class="nx">Y</span><span class="o">.</span><span class="nx">Anim</span><span class="o">.</span><span class="nx">run</span> <span class="o">=</span> <span class="k">function</span><span class="o">()</span> <span class="o">{</span>
321        <span class="k">for</span> <span class="o">(</span><span class="k">var</span> <span class="nx">i</span> <span class="k">in</span> <span class="nx">_instances</span><span class="o">)</span> <span class="o">{</span>
322            <span class="k">if</span> <span class="o">(</span><span class="nx">_instances</span><span class="o">[</span><span class="nx">i</span><span class="o">].</span><span class="nx">run</span><span class="o">)</span> <span class="o">{</span>
323                <span class="nx">_instances</span><span class="o">[</span><span class="nx">i</span><span class="o">].</span><span class="nx">run</span><span class="o">();</span>
324            <span class="o">}</span>
325        <span class="o">}</span>
326    <span class="o">};</span>
327
328    <span class="c">/**</span>
329<span class="c">     * Pauses all animation instances.</span>
330<span class="c">     * @method pause</span>
331<span class="c">     * @static</span>
332<span class="c">     */</span>   
333    <span class="nx">Y</span><span class="o">.</span><span class="nx">Anim</span><span class="o">.</span><span class="nx">pause</span> <span class="o">=</span> <span class="k">function</span><span class="o">()</span> <span class="o">{</span>
334        <span class="k">for</span> <span class="o">(</span><span class="k">var</span> <span class="nx">i</span> <span class="k">in</span> <span class="nx">_running</span><span class="o">)</span> <span class="o">{</span> <span class="c">// stop timer if nothing running</span>
335<span class="c"></span>            <span class="k">if</span> <span class="o">(</span><span class="nx">_running</span><span class="o">[</span><span class="nx">i</span><span class="o">].</span><span class="nx">pause</span><span class="o">)</span> <span class="o">{</span>
336                <span class="nx">_running</span><span class="o">[</span><span class="nx">i</span><span class="o">].</span><span class="nx">pause</span><span class="o">();</span>
337            <span class="o">}</span>
338        <span class="o">}</span>
339        <span class="nx">Y</span><span class="o">.</span><span class="nx">Anim</span><span class="o">.</span><span class="nx">_stopTimer</span><span class="o">();</span>
340    <span class="o">};</span>
341
342    <span class="c">/**</span>
343<span class="c">     * Stops all animation instances.</span>
344<span class="c">     * @method stop</span>
345<span class="c">     * @static</span>
346<span class="c">     */</span>   
347    <span class="nx">Y</span><span class="o">.</span><span class="nx">Anim</span><span class="o">.</span><span class="nx">stop</span> <span class="o">=</span> <span class="k">function</span><span class="o">()</span> <span class="o">{</span>
348        <span class="k">for</span> <span class="o">(</span><span class="k">var</span> <span class="nx">i</span> <span class="k">in</span> <span class="nx">_running</span><span class="o">)</span> <span class="o">{</span> <span class="c">// stop timer if nothing running</span>
349<span class="c"></span>            <span class="k">if</span> <span class="o">(</span><span class="nx">_running</span><span class="o">[</span><span class="nx">i</span><span class="o">].</span><span class="nx">stop</span><span class="o">)</span> <span class="o">{</span>
350                <span class="nx">_running</span><span class="o">[</span><span class="nx">i</span><span class="o">].</span><span class="nx">stop</span><span class="o">();</span>
351            <span class="o">}</span>
352        <span class="o">}</span>
353        <span class="nx">Y</span><span class="o">.</span><span class="nx">Anim</span><span class="o">.</span><span class="nx">_stopTimer</span><span class="o">();</span>
354    <span class="o">};</span>
355   
356    <span class="nx">Y</span><span class="o">.</span><span class="nx">Anim</span><span class="o">.</span><span class="nx">_startTimer</span> <span class="o">=</span> <span class="k">function</span><span class="o">()</span> <span class="o">{</span>
357        <span class="k">if</span> <span class="o">(!</span><span class="nx">_timer</span><span class="o">)</span> <span class="o">{</span>
358            <span class="nx">_timer</span> <span class="o">=</span> <span class="nx">setInterval</span><span class="o">(</span><span class="nx">Y</span><span class="o">.</span><span class="nx">Anim</span><span class="o">.</span><span class="nx">_runFrame</span><span class="o">,</span> <span class="m">1</span><span class="o">);</span>
359        <span class="o">}</span>
360    <span class="o">};</span>
361
362    <span class="nx">Y</span><span class="o">.</span><span class="nx">Anim</span><span class="o">.</span><span class="nx">_stopTimer</span> <span class="o">=</span> <span class="k">function</span><span class="o">()</span> <span class="o">{</span>
363        <span class="nx">clearInterval</span><span class="o">(</span><span class="nx">_timer</span><span class="o">);</span>
364        <span class="nx">_timer</span> <span class="o">=</span> <span class="m">0</span><span class="o">;</span>
365    <span class="o">};</span>
366
367    <span class="c">/**</span>
368<span class="c">     * Called per Interval to handle each animation frame.</span>
369<span class="c">     * @method _runFrame</span>
370<span class="c">     * @private</span>
371<span class="c">     * @static</span>
372<span class="c">     */</span>   
373    <span class="nx">Y</span><span class="o">.</span><span class="nx">Anim</span><span class="o">.</span><span class="nx">_runFrame</span> <span class="o">=</span> <span class="k">function</span><span class="o">()</span> <span class="o">{</span>
374        <span class="k">var</span> <span class="nx">done</span> <span class="o">=</span> <span class="kc">true</span><span class="o">;</span>
375        <span class="k">for</span> <span class="o">(</span><span class="k">var</span> <span class="nx">anim</span> <span class="k">in</span> <span class="nx">_running</span><span class="o">)</span> <span class="o">{</span>
376            <span class="k">if</span> <span class="o">(</span><span class="nx">_running</span><span class="o">[</span><span class="nx">anim</span><span class="o">].</span><span class="nx">_runFrame</span><span class="o">)</span> <span class="o">{</span>
377                <span class="nx">done</span> <span class="o">=</span> <span class="kc">false</span><span class="o">;</span>
378                <span class="nx">_running</span><span class="o">[</span><span class="nx">anim</span><span class="o">].</span><span class="nx">_runFrame</span><span class="o">();</span>
379            <span class="o">}</span>
380        <span class="o">}</span>
381
382        <span class="k">if</span> <span class="o">(</span><span class="nx">done</span><span class="o">)</span> <span class="o">{</span>
383            <span class="nx">Y</span><span class="o">.</span><span class="nx">Anim</span><span class="o">.</span><span class="nx">_stopTimer</span><span class="o">();</span>
384        <span class="o">}</span>
385    <span class="o">};</span>
386
387    <span class="nx">Y</span><span class="o">.</span><span class="nx">Anim</span><span class="o">.</span><span class="nx">RE_UNITS</span> <span class="o">=</span> <span class="sr">/^(-?\d*\.?\d*){1}(em|ex|px|in|cm|mm|pt|pc|%)*$/</span><span class="o">;</span>
388
389    <span class="k">var</span> <span class="nx">proto</span> <span class="o">=</span> <span class="o">{</span>
390        <span class="c">/**</span>
391<span class="c">         * Starts or resumes an animation.</span>
392<span class="c">         * percent start time marker.</span>
393<span class="c">         * @method run</span>
394<span class="c">         * @chainable</span>
395<span class="c">         */</span>   
396        <span class="nx">run</span><span class="o">:</span> <span class="k">function</span><span class="o">()</span> <span class="o">{</span>
397            <span class="k">if</span> <span class="o">(!</span><span class="k">this</span><span class="o">.</span><span class="nx">get</span><span class="o">(</span><span class="nx">RUNNING</span><span class="o">))</span> <span class="o">{</span>
398                <span class="k">this</span><span class="o">.</span><span class="nx">_start</span><span class="o">();</span>
399            <span class="o">}</span> <span class="k">else</span> <span class="k">if</span> <span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">get</span><span class="o">(</span><span class="nx">PAUSED</span><span class="o">))</span> <span class="o">{</span>
400                <span class="k">this</span><span class="o">.</span><span class="nx">_resume</span><span class="o">();</span>
401            <span class="o">}</span>
402            <span class="k">return</span> <span class="k">this</span><span class="o">;</span>
403        <span class="o">},</span>
404
405        <span class="c">/**</span>
406<span class="c">         * Pauses the animation and</span>
407<span class="c">         * freezes it in its current state and time.</span>
408<span class="c">         * Calling run() will continue where it left off.</span>
409<span class="c">         * @method pause</span>
410<span class="c">         * @chainable</span>
411<span class="c">         */</span>   
412        <span class="nx">pause</span><span class="o">:</span> <span class="k">function</span><span class="o">()</span> <span class="o">{</span>
413            <span class="k">if</span> <span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">get</span><span class="o">(</span><span class="nx">RUNNING</span><span class="o">))</span> <span class="o">{</span>
414                <span class="k">this</span><span class="o">.</span><span class="nx">_pause</span><span class="o">();</span>
415            <span class="o">}</span>
416            <span class="k">return</span> <span class="k">this</span><span class="o">;</span>
417        <span class="o">},</span>
418
419        <span class="c">/**</span>
420<span class="c">         * Stops the animation and resets its time.</span>
421<span class="c">         * @method stop</span>
422<span class="c">         * @chainable</span>
423<span class="c">         */</span>   
424        <span class="nx">stop</span><span class="o">:</span> <span class="k">function</span><span class="o">(</span><span class="nx">finish</span><span class="o">)</span> <span class="o">{</span>
425            <span class="k">if</span> <span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">get</span><span class="o">(</span><span class="nx">RUNNING</span><span class="o">)</span> <span class="o">||</span> <span class="k">this</span><span class="o">.</span><span class="nx">get</span><span class="o">(</span><span class="nx">PAUSED</span><span class="o">))</span> <span class="o">{</span>
426                <span class="k">this</span><span class="o">.</span><span class="nx">_end</span><span class="o">(</span><span class="nx">finish</span><span class="o">);</span>
427            <span class="o">}</span>
428            <span class="k">return</span> <span class="k">this</span><span class="o">;</span>
429        <span class="o">},</span>
430
431        <span class="nx">_added</span><span class="o">:</span> <span class="kc">false</span><span class="o">,</span>
432
433        <span class="nx">_start</span><span class="o">:</span> <span class="k">function</span><span class="o">()</span> <span class="o">{</span>
434            <span class="nx">_setPrivate</span><span class="o">(</span><span class="k">this</span><span class="o">,</span> <span class="nx">START_TIME</span><span class="o">,</span> <span class="k">new</span> <span class="nb">Date</span><span class="o">()</span> <span class="o">-</span> <span class="k">this</span><span class="o">.</span><span class="nx">get</span><span class="o">(</span><span class="nx">ELAPSED_TIME</span><span class="o">));</span>
435            <span class="k">this</span><span class="o">.</span><span class="nx">_actualFrames</span> <span class="o">=</span> <span class="m">0</span><span class="o">;</span>
436            <span class="k">if</span> <span class="o">(!</span><span class="k">this</span><span class="o">.</span><span class="nx">get</span><span class="o">(</span><span class="nx">PAUSED</span><span class="o">))</span> <span class="o">{</span>
437                <span class="k">this</span><span class="o">.</span><span class="nx">_initAttr</span><span class="o">();</span>
438            <span class="o">}</span>
439            <span class="nx">_running</span><span class="o">[</span><span class="nx">Y</span><span class="o">.</span><span class="nx">stamp</span><span class="o">(</span><span class="k">this</span><span class="o">)]</span> <span class="o">=</span> <span class="k">this</span><span class="o">;</span>
440            <span class="nx">Y</span><span class="o">.</span><span class="nx">Anim</span><span class="o">.</span><span class="nx">_startTimer</span><span class="o">();</span>
441
442            <span class="k">this</span><span class="o">.</span><span class="nx">fire</span><span class="o">(</span><span class="nx">START</span><span class="o">);</span>
443        <span class="o">},</span>
444
445        <span class="nx">_pause</span><span class="o">:</span> <span class="k">function</span><span class="o">()</span> <span class="o">{</span>
446            <span class="nx">_setPrivate</span><span class="o">(</span><span class="k">this</span><span class="o">,</span> <span class="nx">START_TIME</span><span class="o">,</span> <span class="kc">null</span><span class="o">);</span>
447            <span class="nx">_setPrivate</span><span class="o">(</span><span class="k">this</span><span class="o">,</span> <span class="nx">PAUSED</span><span class="o">,</span> <span class="kc">true</span><span class="o">);</span>
448            <span class="nx">delete</span> <span class="nx">_running</span><span class="o">[</span><span class="nx">Y</span><span class="o">.</span><span class="nx">stamp</span><span class="o">(</span><span class="k">this</span><span class="o">)];</span>
449
450            <span class="c">/**</span>
451<span class="c">            * @event pause</span>
452<span class="c">            * @description fires when an animation is paused.</span>
453<span class="c">            * @param {Event} ev The pause event.</span>
454<span class="c">            * @type Event.Custom</span>
455<span class="c">            */</span>
456            <span class="k">this</span><span class="o">.</span><span class="nx">fire</span><span class="o">(</span><span class="s1">&#39;pause&#39;</span><span class="o">);</span>
457        <span class="o">},</span>
458
459        <span class="nx">_resume</span><span class="o">:</span> <span class="k">function</span><span class="o">()</span> <span class="o">{</span>
460            <span class="nx">_setPrivate</span><span class="o">(</span><span class="k">this</span><span class="o">,</span> <span class="nx">PAUSED</span><span class="o">,</span> <span class="kc">false</span><span class="o">);</span>
461            <span class="nx">_running</span><span class="o">[</span><span class="nx">Y</span><span class="o">.</span><span class="nx">stamp</span><span class="o">(</span><span class="k">this</span><span class="o">)]</span> <span class="o">=</span> <span class="k">this</span><span class="o">;</span>
462
463            <span class="c">/**</span>
464<span class="c">            * @event resume</span>
465<span class="c">            * @description fires when an animation is resumed (run from pause).</span>
466<span class="c">            * @param {Event} ev The pause event.</span>
467<span class="c">            * @type Event.Custom</span>
468<span class="c">            */</span>
469            <span class="k">this</span><span class="o">.</span><span class="nx">fire</span><span class="o">(</span><span class="s1">&#39;resume&#39;</span><span class="o">);</span>
470        <span class="o">},</span>
471
472        <span class="nx">_end</span><span class="o">:</span> <span class="k">function</span><span class="o">(</span><span class="nx">finish</span><span class="o">)</span> <span class="o">{</span>
473            <span class="nx">_setPrivate</span><span class="o">(</span><span class="k">this</span><span class="o">,</span> <span class="nx">START_TIME</span><span class="o">,</span> <span class="kc">null</span><span class="o">);</span>
474            <span class="nx">_setPrivate</span><span class="o">(</span><span class="k">this</span><span class="o">,</span> <span class="nx">ELAPSED_TIME</span><span class="o">,</span> <span class="m">0</span><span class="o">);</span>
475            <span class="nx">_setPrivate</span><span class="o">(</span><span class="k">this</span><span class="o">,</span> <span class="nx">PAUSED</span><span class="o">,</span> <span class="kc">false</span><span class="o">);</span>
476            <span class="c">//_setPrivate(this, REVERSE, false);</span>
477<span class="c"></span>
478            <span class="nx">delete</span> <span class="nx">_running</span><span class="o">[</span><span class="nx">Y</span><span class="o">.</span><span class="nx">stamp</span><span class="o">(</span><span class="k">this</span><span class="o">)];</span>
479            <span class="k">this</span><span class="o">.</span><span class="nx">fire</span><span class="o">(</span><span class="nx">END</span><span class="o">,</span> <span class="o">{</span><span class="nx">elapsed</span><span class="o">:</span> <span class="k">this</span><span class="o">.</span><span class="nx">get</span><span class="o">(</span><span class="nx">ELAPSED_TIME</span><span class="o">)});</span>
480        <span class="o">},</span>
481
482        <span class="nx">_runFrame</span><span class="o">:</span> <span class="k">function</span><span class="o">()</span> <span class="o">{</span>
483            <span class="k">var</span> <span class="nx">attr</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">_runtimeAttr</span><span class="o">,</span>
484                <span class="nx">customAttr</span> <span class="o">=</span> <span class="nx">Y</span><span class="o">.</span><span class="nx">Anim</span><span class="o">.</span><span class="nx">behaviors</span><span class="o">,</span>
485                <span class="nx">easing</span> <span class="o">=</span> <span class="nx">attr</span><span class="o">.</span><span class="nx">easing</span><span class="o">,</span>
486                <span class="nx">d</span> <span class="o">=</span> <span class="nx">attr</span><span class="o">.</span><span class="nx">duration</span><span class="o">,</span>
487                <span class="nx">t</span> <span class="o">=</span> <span class="k">new</span> <span class="nb">Date</span><span class="o">()</span> <span class="o">-</span> <span class="k">this</span><span class="o">.</span><span class="nx">get</span><span class="o">(</span><span class="nx">START_TIME</span><span class="o">),</span>
488                <span class="nx">reversed</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">get</span><span class="o">(</span><span class="nx">REVERSE</span><span class="o">),</span>
489                <span class="nx">done</span> <span class="o">=</span> <span class="o">(</span><span class="nx">t</span> <span class="o">&gt;=</span> <span class="nx">d</span><span class="o">),</span>
490                <span class="nx">lastFrame</span> <span class="o">=</span> <span class="nx">d</span><span class="o">,</span>
491                <span class="nx">attribute</span><span class="o">,</span>
492                <span class="nx">setter</span><span class="o">;</span>
493               
494            <span class="k">if</span> <span class="o">(</span><span class="nx">reversed</span><span class="o">)</span> <span class="o">{</span>
495                <span class="nx">t</span> <span class="o">=</span> <span class="nx">d</span> <span class="o">-</span> <span class="nx">t</span><span class="o">;</span>
496                <span class="nx">done</span> <span class="o">=</span> <span class="o">(</span><span class="nx">t</span> <span class="o">&lt;=</span> <span class="m">0</span><span class="o">);</span>
497                <span class="nx">lastFrame</span> <span class="o">=</span> <span class="m">0</span><span class="o">;</span>
498            <span class="o">}</span>
499
500            <span class="k">for</span> <span class="o">(</span><span class="k">var</span> <span class="nx">i</span> <span class="k">in</span> <span class="nx">attr</span><span class="o">)</span> <span class="o">{</span>
501                <span class="k">if</span> <span class="o">(</span><span class="nx">attr</span><span class="o">[</span><span class="nx">i</span><span class="o">].</span><span class="nx">to</span><span class="o">)</span> <span class="o">{</span>
502                    <span class="nx">attribute</span> <span class="o">=</span> <span class="nx">attr</span><span class="o">[</span><span class="nx">i</span><span class="o">];</span>
503                    <span class="nx">setter</span> <span class="o">=</span> <span class="o">(</span><span class="nx">i</span> <span class="k">in</span> <span class="nx">customAttr</span> <span class="o">&amp;&amp;</span> <span class="s1">&#39;set&#39;</span> <span class="k">in</span> <span class="nx">customAttr</span><span class="o">[</span><span class="nx">i</span><span class="o">])</span> <span class="o">?</span>
504                            <span class="nx">customAttr</span><span class="o">[</span><span class="nx">i</span><span class="o">].</span><span class="nx">set</span> <span class="o">:</span> <span class="nx">Y</span><span class="o">.</span><span class="nx">Anim</span><span class="o">.</span><span class="nx">DEFAULT_SETTER</span><span class="o">;</span>
505
506                    <span class="k">if</span> <span class="o">(!</span><span class="nx">done</span><span class="o">)</span> <span class="o">{</span>
507                        <span class="nx">setter</span><span class="o">(</span><span class="k">this</span><span class="o">,</span> <span class="nx">i</span><span class="o">,</span> <span class="nx">attribute</span><span class="o">.</span><span class="nx">from</span><span class="o">,</span> <span class="nx">attribute</span><span class="o">.</span><span class="nx">to</span><span class="o">,</span> <span class="nx">t</span><span class="o">,</span> <span class="nx">d</span><span class="o">,</span> <span class="nx">easing</span><span class="o">,</span> <span class="nx">attribute</span><span class="o">.</span><span class="nx">unit</span><span class="o">);</span> 
508                    <span class="o">}</span> <span class="k">else</span> <span class="o">{</span> <span class="c">// ensure final frame value is set</span>
509<span class="c"></span>                       <span class="c">// TODO: handle keyframes </span>
510<span class="c"></span>                        <span class="nx">setter</span><span class="o">(</span><span class="k">this</span><span class="o">,</span> <span class="nx">i</span><span class="o">,</span> <span class="nx">attribute</span><span class="o">.</span><span class="nx">from</span><span class="o">,</span> <span class="nx">attribute</span><span class="o">.</span><span class="nx">to</span><span class="o">,</span> <span class="nx">lastFrame</span><span class="o">,</span> <span class="nx">d</span><span class="o">,</span> <span class="nx">easing</span><span class="o">,</span> <span class="nx">attribute</span><span class="o">.</span><span class="nx">unit</span><span class="o">);</span> 
511                    <span class="o">}</span>
512                <span class="o">}</span>
513            <span class="o">}</span>
514
515            <span class="k">this</span><span class="o">.</span><span class="nx">_actualFrames</span> <span class="o">+=</span> <span class="m">1</span><span class="o">;</span>
516            <span class="nx">_setPrivate</span><span class="o">(</span><span class="k">this</span><span class="o">,</span> <span class="nx">ELAPSED_TIME</span><span class="o">,</span> <span class="nx">t</span><span class="o">);</span>
517
518            <span class="k">this</span><span class="o">.</span><span class="nx">fire</span><span class="o">(</span><span class="nx">TWEEN</span><span class="o">);</span>
519            <span class="k">if</span> <span class="o">(</span><span class="nx">done</span><span class="o">)</span> <span class="o">{</span>
520                <span class="k">this</span><span class="o">.</span><span class="nx">_lastFrame</span><span class="o">();</span>
521            <span class="o">}</span>
522        <span class="o">},</span>
523
524        <span class="nx">_lastFrame</span><span class="o">:</span> <span class="k">function</span><span class="o">()</span> <span class="o">{</span>
525            <span class="k">var</span> <span class="nx">iter</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">get</span><span class="o">(</span><span class="s1">&#39;iterations&#39;</span><span class="o">),</span>
526                <span class="nx">iterCount</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">get</span><span class="o">(</span><span class="nx">ITERATION_COUNT</span><span class="o">);</span>
527
528            <span class="nx">iterCount</span> <span class="o">+=</span> <span class="m">1</span><span class="o">;</span>
529            <span class="k">if</span> <span class="o">(</span><span class="nx">iter</span> <span class="o">===</span> <span class="s1">&#39;infinite&#39;</span> <span class="o">||</span> <span class="nx">iterCount</span> <span class="o">&lt;</span> <span class="nx">iter</span><span class="o">)</span> <span class="o">{</span>
530                <span class="k">if</span> <span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">get</span><span class="o">(</span><span class="s1">&#39;direction&#39;</span><span class="o">)</span> <span class="o">===</span> <span class="s1">&#39;alternate&#39;</span><span class="o">)</span> <span class="o">{</span>
531                    <span class="k">this</span><span class="o">.</span><span class="nx">set</span><span class="o">(</span><span class="nx">REVERSE</span><span class="o">,</span> <span class="o">!</span><span class="k">this</span><span class="o">.</span><span class="nx">get</span><span class="o">(</span><span class="nx">REVERSE</span><span class="o">));</span> <span class="c">// flip it</span>
532<span class="c"></span>                <span class="o">}</span>
533                <span class="c">/**</span>
534<span class="c">                * @event iteration</span>
535<span class="c">                * @description fires when an animation begins an iteration.</span>
536<span class="c">                * @param {Event} ev The iteration event.</span>
537<span class="c">                * @type Event.Custom</span>
538<span class="c">                */</span>
539                <span class="k">this</span><span class="o">.</span><span class="nx">fire</span><span class="o">(</span><span class="s1">&#39;iteration&#39;</span><span class="o">);</span>
540            <span class="o">}</span> <span class="k">else</span> <span class="o">{</span>
541                <span class="nx">iterCount</span> <span class="o">=</span> <span class="m">0</span><span class="o">;</span>
542                <span class="k">this</span><span class="o">.</span><span class="nx">_end</span><span class="o">();</span>
543            <span class="o">}</span>
544
545            <span class="nx">_setPrivate</span><span class="o">(</span><span class="k">this</span><span class="o">,</span> <span class="nx">START_TIME</span><span class="o">,</span> <span class="k">new</span> <span class="nb">Date</span><span class="o">());</span>
546            <span class="nx">_setPrivate</span><span class="o">(</span><span class="k">this</span><span class="o">,</span> <span class="nx">ITERATION_COUNT</span><span class="o">,</span> <span class="nx">iterCount</span><span class="o">);</span>
547        <span class="o">},</span>
548
549        <span class="nx">_initAttr</span><span class="o">:</span> <span class="k">function</span><span class="o">()</span> <span class="o">{</span>
550            <span class="k">var</span> <span class="nx">from</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">get</span><span class="o">(</span><span class="s1">&#39;from&#39;</span><span class="o">)</span> <span class="o">||</span> <span class="o">{},</span>
551                <span class="nx">to</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">get</span><span class="o">(</span><span class="s1">&#39;to&#39;</span><span class="o">)</span> <span class="o">||</span> <span class="o">{},</span>
552                <span class="nx">dur</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">get</span><span class="o">(</span><span class="s1">&#39;duration&#39;</span><span class="o">)</span> <span class="o">*</span> <span class="m">1000</span><span class="o">,</span>
553                <span class="nx">node</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">get</span><span class="o">(</span><span class="nx">NODE</span><span class="o">),</span>
554                <span class="nx">easing</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">get</span><span class="o">(</span><span class="s1">&#39;easing&#39;</span><span class="o">)</span> <span class="o">||</span> <span class="o">{},</span>
555                <span class="nx">attr</span> <span class="o">=</span> <span class="o">{},</span>
556                <span class="nx">customAttr</span> <span class="o">=</span> <span class="nx">Y</span><span class="o">.</span><span class="nx">Anim</span><span class="o">.</span><span class="nx">behaviors</span><span class="o">,</span>
557                <span class="nx">unit</span><span class="o">,</span> <span class="nx">begin</span><span class="o">,</span> <span class="nx">end</span><span class="o">;</span>
558
559            <span class="nx">Y</span><span class="o">.</span><span class="nx">each</span><span class="o">(</span><span class="nx">to</span><span class="o">,</span> <span class="k">function</span><span class="o">(</span><span class="nx">val</span><span class="o">,</span> <span class="nx">name</span><span class="o">)</span> <span class="o">{</span>
560                <span class="k">if</span> <span class="o">(</span><span class="k">typeof</span> <span class="nx">val</span> <span class="o">===</span> <span class="s1">&#39;function&#39;</span><span class="o">)</span> <span class="o">{</span>
561                    <span class="nx">val</span> <span class="o">=</span> <span class="nx">val</span><span class="o">.</span><span class="nx">call</span><span class="o">(</span><span class="k">this</span><span class="o">,</span> <span class="nx">node</span><span class="o">);</span>
562                <span class="o">}</span>
563
564                <span class="nx">begin</span> <span class="o">=</span> <span class="nx">from</span><span class="o">[</span><span class="nx">name</span><span class="o">];</span>
565                <span class="k">if</span> <span class="o">(</span><span class="nx">begin</span> <span class="o">===</span> <span class="kc">undefined</span><span class="o">)</span> <span class="o">{</span>
566                    <span class="nx">begin</span> <span class="o">=</span> <span class="o">(</span><span class="nx">name</span> <span class="k">in</span> <span class="nx">customAttr</span> <span class="o">&amp;&amp;</span> <span class="s1">&#39;get&#39;</span> <span class="k">in</span> <span class="nx">customAttr</span><span class="o">[</span><span class="nx">name</span><span class="o">])</span>  <span class="o">?</span>
567                            <span class="nx">customAttr</span><span class="o">[</span><span class="nx">name</span><span class="o">].</span><span class="nx">get</span><span class="o">(</span><span class="k">this</span><span class="o">,</span> <span class="nx">name</span><span class="o">)</span> <span class="o">:</span> <span class="nx">Y</span><span class="o">.</span><span class="nx">Anim</span><span class="o">.</span><span class="nx">DEFAULT_GETTER</span><span class="o">(</span><span class="k">this</span><span class="o">,</span> <span class="nx">name</span><span class="o">);</span>
568                <span class="o">}</span> <span class="k">else</span> <span class="k">if</span> <span class="o">(</span><span class="k">typeof</span> <span class="nx">begin</span> <span class="o">===</span> <span class="s1">&#39;function&#39;</span><span class="o">)</span> <span class="o">{</span>
569                    <span class="nx">begin</span> <span class="o">=</span> <span class="nx">begin</span><span class="o">.</span><span class="nx">call</span><span class="o">(</span><span class="k">this</span><span class="o">,</span> <span class="nx">node</span><span class="o">);</span>
570                <span class="o">}</span>
571
572                <span class="k">var</span> <span class="nx">mFrom</span> <span class="o">=</span> <span class="nx">Y</span><span class="o">.</span><span class="nx">Anim</span><span class="o">.</span><span class="nx">RE_UNITS</span><span class="o">.</span><span class="nx">exec</span><span class="o">(</span><span class="nx">begin</span><span class="o">);</span>
573                <span class="k">var</span> <span class="nx">mTo</span> <span class="o">=</span> <span class="nx">Y</span><span class="o">.</span><span class="nx">Anim</span><span class="o">.</span><span class="nx">RE_UNITS</span><span class="o">.</span><span class="nx">exec</span><span class="o">(</span><span class="nx">val</span><span class="o">);</span>
574
575                <span class="nx">begin</span> <span class="o">=</span> <span class="nx">mFrom</span> <span class="o">?</span> <span class="nx">mFrom</span><span class="o">[</span><span class="m">1</span><span class="o">]</span> <span class="o">:</span> <span class="nx">begin</span><span class="o">;</span>
576                <span class="k">var</span> <span class="nx">end</span> <span class="o">=</span> <span class="nx">mTo</span> <span class="o">?</span> <span class="nx">mTo</span><span class="o">[</span><span class="m">1</span><span class="o">]</span> <span class="o">:</span> <span class="nx">val</span><span class="o">,</span>
577                    <span class="nx">unit</span> <span class="o">=</span> <span class="nx">mTo</span> <span class="o">?</span> <span class="nx">mTo</span><span class="o">[</span><span class="m">2</span><span class="o">]</span> <span class="o">:</span> <span class="nx">mFrom</span> <span class="o">?</span>  <span class="nx">mFrom</span><span class="o">[</span><span class="m">2</span><span class="o">]</span> <span class="o">:</span> <span class="s1">&#39;&#39;</span><span class="o">;</span> <span class="c">// one might be zero TODO: mixed units</span>
578<span class="c"></span>
579                <span class="k">if</span> <span class="o">(!</span><span class="nx">unit</span> <span class="o">&amp;&amp;</span> <span class="nx">Y</span><span class="o">.</span><span class="nx">Anim</span><span class="o">.</span><span class="nx">RE_DEFAULT_UNIT</span><span class="o">.</span><span class="nx">test</span><span class="o">(</span><span class="nx">name</span><span class="o">))</span> <span class="o">{</span>
580                    <span class="nx">unit</span> <span class="o">=</span> <span class="nx">Y</span><span class="o">.</span><span class="nx">Anim</span><span class="o">.</span><span class="nx">DEFAULT_UNIT</span><span class="o">;</span>
581                <span class="o">}</span>
582
583                <span class="k">if</span> <span class="o">(!</span><span class="nx">begin</span> <span class="o">||</span> <span class="o">!</span><span class="nx">end</span><span class="o">)</span> <span class="o">{</span>
584                    <span class="nx">Y</span><span class="o">.</span><span class="nx">fail</span><span class="o">(</span><span class="s1">&#39;invalid &quot;from&quot; or &quot;to&quot; for &quot;&#39;</span> <span class="o">+</span> <span class="nx">name</span> <span class="o">+</span> <span class="s1">&#39;&quot;&#39;</span><span class="o">,</span> <span class="s1">&#39;Anim&#39;</span><span class="o">);</span>
585                    <span class="k">return</span><span class="o">;</span>
586                <span class="o">}</span>
587
588                <span class="nx">attr</span><span class="o">[</span><span class="nx">name</span><span class="o">]</span> <span class="o">=</span> <span class="o">{</span>
589                    <span class="nx">from</span><span class="o">:</span> <span class="nx">begin</span><span class="o">,</span>
590                    <span class="nx">to</span><span class="o">:</span> <span class="nx">end</span><span class="o">,</span>
591                    <span class="nx">unit</span><span class="o">:</span> <span class="nx">unit</span>
592                <span class="o">};</span>
593
594                <span class="nx">attr</span><span class="o">.</span><span class="nx">duration</span> <span class="o">=</span> <span class="nx">dur</span><span class="o">;</span>
595                <span class="nx">attr</span><span class="o">.</span><span class="nx">easing</span> <span class="o">=</span> <span class="nx">easing</span><span class="o">;</span>
596
597            <span class="o">},</span> <span class="k">this</span><span class="o">);</span>
598
599            <span class="k">this</span><span class="o">.</span><span class="nx">_runtimeAttr</span> <span class="o">=</span> <span class="nx">attr</span><span class="o">;</span>
600        <span class="o">},</span>
601
602
603        <span class="c">// TODO: move to computedStyle? (browsers dont agree on default computed offsets)</span>
604<span class="c"></span>        <span class="nx">_getOffset</span><span class="o">:</span> <span class="k">function</span><span class="o">(</span><span class="nx">attr</span><span class="o">)</span> <span class="o">{</span>
605            <span class="k">var</span> <span class="nx">node</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">_node</span><span class="o">,</span>
606                <span class="nx">val</span> <span class="o">=</span> <span class="nx">node</span><span class="o">.</span><span class="nx">getComputedStyle</span><span class="o">(</span><span class="nx">attr</span><span class="o">),</span>
607                <span class="nx">get</span> <span class="o">=</span> <span class="o">(</span><span class="nx">attr</span> <span class="o">===</span> <span class="s1">&#39;left&#39;</span><span class="o">)</span> <span class="o">?</span> <span class="s1">&#39;getX&#39;</span><span class="o">:</span> <span class="s1">&#39;getY&#39;</span><span class="o">,</span>
608                <span class="nx">set</span> <span class="o">=</span> <span class="o">(</span><span class="nx">attr</span> <span class="o">===</span> <span class="s1">&#39;left&#39;</span><span class="o">)</span> <span class="o">?</span> <span class="s1">&#39;setX&#39;</span><span class="o">:</span> <span class="s1">&#39;setY&#39;</span><span class="o">;</span>
609
610            <span class="k">if</span> <span class="o">(</span><span class="nx">val</span> <span class="o">===</span> <span class="s1">&#39;auto&#39;</span><span class="o">)</span> <span class="o">{</span>
611                <span class="k">var</span> <span class="nx">position</span> <span class="o">=</span> <span class="nx">node</span><span class="o">.</span><span class="nx">getStyle</span><span class="o">(</span><span class="s1">&#39;position&#39;</span><span class="o">);</span>
612                <span class="k">if</span> <span class="o">(</span><span class="nx">position</span> <span class="o">===</span> <span class="s1">&#39;absolute&#39;</span> <span class="o">||</span> <span class="nx">position</span> <span class="o">===</span> <span class="s1">&#39;fixed&#39;</span><span class="o">)</span> <span class="o">{</span>
613                    <span class="nx">val</span> <span class="o">=</span> <span class="nx">node</span><span class="o">[</span><span class="nx">get</span><span class="o">]();</span>
614                    <span class="nx">node</span><span class="o">[</span><span class="nx">set</span><span class="o">](</span><span class="nx">val</span><span class="o">);</span>
615                <span class="o">}</span> <span class="k">else</span> <span class="o">{</span>
616                    <span class="nx">val</span> <span class="o">=</span> <span class="m">0</span><span class="o">;</span>
617                <span class="o">}</span>
618            <span class="o">}</span>
619
620            <span class="k">return</span> <span class="nx">val</span><span class="o">;</span>
621        <span class="o">}</span>
622    <span class="o">};</span>
623
624    <span class="nx">Y</span><span class="o">.</span><span class="nx">extend</span><span class="o">(</span><span class="nx">Y</span><span class="o">.</span><span class="nx">Anim</span><span class="o">,</span> <span class="nx">Y</span><span class="o">.</span><span class="nx">Base</span><span class="o">,</span> <span class="nx">proto</span><span class="o">);</span>
625</pre></div>
626                    </div>
627                        </div>
628                </div>
629                <div class="yui-b">
630            <div class="nav">
631
632                    <div class="module">
633                        <h4>Modules</h4>
634                        <ul class="content">
635
636                                <li class="selected"><a href="module_anim.html">anim</a></li>
637
638                                <li class=""><a href="module_attribute.html">attribute</a></li>
639
640                                <li class=""><a href="module_base.html">base</a></li>
641
642                                <li class=""><a href="module_cookie.html">cookie</a></li>
643
644                                <li class=""><a href="module_dd.html">dd</a></li>
645
646                                <li class=""><a href="module_dd-plugin.html">dd-plugin</a></li>
647
648                                <li class=""><a href="module_dom.html">dom</a></li>
649
650                                <li class=""><a href="module_dump.html">dump</a></li>
651
652                                <li class=""><a href="module_event.html">event</a></li>
653
654                                <li class=""><a href="module_io.html">io</a></li>
655
656                                <li class=""><a href="module_json.html">json</a></li>
657
658                                <li class=""><a href="module_node.html">node</a></li>
659
660                                <li class=""><a href="module_oop.html">oop</a></li>
661
662                                <li class=""><a href="module_queue.html">queue</a></li>
663
664                                <li class=""><a href="module_substitute.html">substitute</a></li>
665
666                                <li class=""><a href="module_yui.html">yui</a></li>
667                        </ul>
668                    </div>
669
670                    <div class="module">
671                        <h4>Classes</h4>
672                        <ul class="content">
673                                <li class=""><a href="Anim.html">Anim</a></li>
674                                <li class=""><a href="Easing.html">Easing</a></li>
675                        </ul>
676                    </div>
677
678                    <div class="module">
679                        <h4>Files</h4>
680                        <ul class="content">       
681                                <li class=""><a href="anim-color.js.html">anim-color.js</a></li>
682                                <li class=""><a href="anim-curve.js.html">anim-curve.js</a></li>
683                                <li class=""><a href="anim-easing.js.html">anim-easing.js</a></li>
684                                <li class=""><a href="anim-node-plugin.js.html">anim-node-plugin.js</a></li>
685                                <li class=""><a href="anim-scroll.js.html">anim-scroll.js</a></li>
686                                <li class=""><a href="anim-xy.js.html">anim-xy.js</a></li>
687                                <li class="selected"><a href="anim.js.html">anim.js</a></li>
688                        </ul>
689                    </div>
690
691
692
693
694
695            </div>
696                </div>
697        </div>
698        <div id="ft">
699        <hr />
700        Copyright &copy; 2008 Yahoo! Inc. All rights reserved.
701        </div>
702</div>
703</body>
704</html>
Note: See TracBrowser for help on using the repository browser.