/loggerhead/trunk

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/loggerhead/trunk

« back to all changes in this revision

Viewing changes to loggerhead/static/javascript/yui/build/anim/anim-easing-debug.js

  • Committer: Martin Albisetti
  • Date: 2008-12-22 15:16:45 UTC
  • mfrom: (255 trunk)
  • mto: (157.1.8 loggerhead)
  • mto: This revision was merged to the branch mainline in revision 423.
  • Revision ID: argentina@gmail.com-20081222151645-vqxhqpr0fx9rc9t1
Merge from trunk revno 256

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
Copyright (c) 2008, Yahoo! Inc. All rights reserved.
 
3
Code licensed under the BSD License:
 
4
http://developer.yahoo.net/yui/license.txt
 
5
version: 3.0.0pr1
 
6
*/
 
7
YUI.add('anim-easing', function(Y) {
 
8
 
 
9
/*
 
10
TERMS OF USE - EASING EQUATIONS
 
11
Open source under the BSD License.
 
12
Copyright 2001 Robert Penner All rights reserved.
 
13
 
 
14
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
 
15
 
 
16
 * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
 
17
 * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
 
18
 * Neither the name of the author nor the names of contributors may be used to endorse or promote products derived from this software without specific prior written permission.
 
19
 
 
20
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
21
*/
 
22
 
 
23
/**
 
24
 * The easing module provides methods for customizing
 
25
 * how an animation behaves during each run.
 
26
 * @class Easing
 
27
 * @module anim
 
28
 * @submodule anim-easing
 
29
 */
 
30
 
 
31
Y.Easing = {
 
32
 
 
33
    /**
 
34
     * Uniform speed between points.
 
35
     * @method easeNone
 
36
     * @param {Number} t Time value used to compute current value
 
37
     * @param {Number} b Starting value
 
38
     * @param {Number} c Delta between start and end values
 
39
     * @param {Number} d Total length of animation
 
40
     * @return {Number} The computed value for the current animation frame
 
41
     */
 
42
    easeNone: function (t, b, c, d) {
 
43
        return c*t/d + b;
 
44
    },
 
45
    
 
46
    /**
 
47
     * Begins slowly and accelerates towards end. (quadratic)
 
48
     * @method easeIn
 
49
     * @param {Number} t Time value used to compute current value
 
50
     * @param {Number} b Starting value
 
51
     * @param {Number} c Delta between start and end values
 
52
     * @param {Number} d Total length of animation
 
53
     * @return {Number} The computed value for the current animation frame
 
54
     */
 
55
    easeIn: function (t, b, c, d) {
 
56
        return c*(t/=d)*t + b;
 
57
    },
 
58
 
 
59
    /**
 
60
     * Begins quickly and decelerates towards end.  (quadratic)
 
61
     * @method easeOut
 
62
     * @param {Number} t Time value used to compute current value
 
63
     * @param {Number} b Starting value
 
64
     * @param {Number} c Delta between start and end values
 
65
     * @param {Number} d Total length of animation
 
66
     * @return {Number} The computed value for the current animation frame
 
67
     */
 
68
    easeOut: function (t, b, c, d) {
 
69
        return -c *(t/=d)*(t-2) + b;
 
70
    },
 
71
    
 
72
    /**
 
73
     * Begins slowly and decelerates towards end. (quadratic)
 
74
     * @method easeBoth
 
75
     * @param {Number} t Time value used to compute current value
 
76
     * @param {Number} b Starting value
 
77
     * @param {Number} c Delta between start and end values
 
78
     * @param {Number} d Total length of animation
 
79
     * @return {Number} The computed value for the current animation frame
 
80
     */
 
81
    easeBoth: function (t, b, c, d) {
 
82
        if ((t/=d/2) < 1) {
 
83
            return c/2*t*t + b;
 
84
        }
 
85
        
 
86
        return -c/2 * ((--t)*(t-2) - 1) + b;
 
87
    },
 
88
    
 
89
    /**
 
90
     * Begins slowly and accelerates towards end. (quartic)
 
91
     * @method easeInStrong
 
92
     * @param {Number} t Time value used to compute current value
 
93
     * @param {Number} b Starting value
 
94
     * @param {Number} c Delta between start and end values
 
95
     * @param {Number} d Total length of animation
 
96
     * @return {Number} The computed value for the current animation frame
 
97
     */
 
98
    easeInStrong: function (t, b, c, d) {
 
99
        return c*(t/=d)*t*t*t + b;
 
100
    },
 
101
    
 
102
    /**
 
103
     * Begins quickly and decelerates towards end.  (quartic)
 
104
     * @method easeOutStrong
 
105
     * @param {Number} t Time value used to compute current value
 
106
     * @param {Number} b Starting value
 
107
     * @param {Number} c Delta between start and end values
 
108
     * @param {Number} d Total length of animation
 
109
     * @return {Number} The computed value for the current animation frame
 
110
     */
 
111
    easeOutStrong: function (t, b, c, d) {
 
112
        return -c * ((t=t/d-1)*t*t*t - 1) + b;
 
113
    },
 
114
    
 
115
    /**
 
116
     * Begins slowly and decelerates towards end. (quartic)
 
117
     * @method easeBothStrong
 
118
     * @param {Number} t Time value used to compute current value
 
119
     * @param {Number} b Starting value
 
120
     * @param {Number} c Delta between start and end values
 
121
     * @param {Number} d Total length of animation
 
122
     * @return {Number} The computed value for the current animation frame
 
123
     */
 
124
    easeBothStrong: function (t, b, c, d) {
 
125
        if ((t/=d/2) < 1) {
 
126
            return c/2*t*t*t*t + b;
 
127
        }
 
128
        
 
129
        return -c/2 * ((t-=2)*t*t*t - 2) + b;
 
130
    },
 
131
 
 
132
    /**
 
133
     * Snap in elastic effect.
 
134
     * @method elasticIn
 
135
     * @param {Number} t Time value used to compute current value
 
136
     * @param {Number} b Starting value
 
137
     * @param {Number} c Delta between start and end values
 
138
     * @param {Number} d Total length of animation
 
139
     * @param {Number} a Amplitude (optional)
 
140
     * @param {Number} p Period (optional)
 
141
     * @return {Number} The computed value for the current animation frame
 
142
     */
 
143
 
 
144
    elasticIn: function (t, b, c, d, a, p) {
 
145
        var s;
 
146
        if (t === 0) {
 
147
            return b;
 
148
        }
 
149
        if ( (t /= d) === 1 ) {
 
150
            return b+c;
 
151
        }
 
152
        if (!p) {
 
153
            p = d* 0.3;
 
154
        }
 
155
        
 
156
        if (!a || a < Math.abs(c)) {
 
157
            a = c; 
 
158
            s = p/4;
 
159
        }
 
160
        else {
 
161
            s = p/(2*Math.PI) * Math.asin (c/a);
 
162
        }
 
163
        
 
164
        return -(a*Math.pow(2,10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )) + b;
 
165
    },
 
166
 
 
167
    /**
 
168
     * Snap out elastic effect.
 
169
     * @method elasticOut
 
170
     * @param {Number} t Time value used to compute current value
 
171
     * @param {Number} b Starting value
 
172
     * @param {Number} c Delta between start and end values
 
173
     * @param {Number} d Total length of animation
 
174
     * @param {Number} a Amplitude (optional)
 
175
     * @param {Number} p Period (optional)
 
176
     * @return {Number} The computed value for the current animation frame
 
177
     */
 
178
    elasticOut: function (t, b, c, d, a, p) {
 
179
        var s;
 
180
        if (t === 0) {
 
181
            return b;
 
182
        }
 
183
        if ( (t /= d) === 1 ) {
 
184
            return b+c;
 
185
        }
 
186
        if (!p) {
 
187
            p=d * 0.3;
 
188
        }
 
189
        
 
190
        if (!a || a < Math.abs(c)) {
 
191
            a = c;
 
192
            s = p / 4;
 
193
        }
 
194
        else {
 
195
            s = p/(2*Math.PI) * Math.asin (c/a);
 
196
        }
 
197
        
 
198
        return a*Math.pow(2,-10*t) * Math.sin( (t*d-s)*(2*Math.PI)/p ) + c + b;
 
199
    },
 
200
    
 
201
    /**
 
202
     * Snap both elastic effect.
 
203
     * @method elasticBoth
 
204
     * @param {Number} t Time value used to compute current value
 
205
     * @param {Number} b Starting value
 
206
     * @param {Number} c Delta between start and end values
 
207
     * @param {Number} d Total length of animation
 
208
     * @param {Number} a Amplitude (optional)
 
209
     * @param {Number} p Period (optional)
 
210
     * @return {Number} The computed value for the current animation frame
 
211
     */
 
212
    elasticBoth: function (t, b, c, d, a, p) {
 
213
        var s;
 
214
        if (t === 0) {
 
215
            return b;
 
216
        }
 
217
        
 
218
        if ( (t /= d/2) === 2 ) {
 
219
            return b+c;
 
220
        }
 
221
        
 
222
        if (!p) {
 
223
            p = d*(0.3*1.5);
 
224
        }
 
225
        
 
226
        if ( !a || a < Math.abs(c) ) {
 
227
            a = c; 
 
228
            s = p/4;
 
229
        }
 
230
        else {
 
231
            s = p/(2*Math.PI) * Math.asin (c/a);
 
232
        }
 
233
        
 
234
        if (t < 1) {
 
235
            return -0.5*(a*Math.pow(2,10*(t-=1)) * 
 
236
                    Math.sin( (t*d-s)*(2*Math.PI)/p )) + b;
 
237
        }
 
238
        return a*Math.pow(2,-10*(t-=1)) * 
 
239
                Math.sin( (t*d-s)*(2*Math.PI)/p )*0.5 + c + b;
 
240
    },
 
241
 
 
242
 
 
243
    /**
 
244
     * Backtracks slightly, then reverses direction and moves to end.
 
245
     * @method backIn
 
246
     * @param {Number} t Time value used to compute current value
 
247
     * @param {Number} b Starting value
 
248
     * @param {Number} c Delta between start and end values
 
249
     * @param {Number} d Total length of animation
 
250
     * @param {Number} s Overshoot (optional)
 
251
     * @return {Number} The computed value for the current animation frame
 
252
     */
 
253
    backIn: function (t, b, c, d, s) {
 
254
        if (s == undefined) {
 
255
            s = 1.70158;
 
256
        }
 
257
        if (t === d) {
 
258
            t -= 0.001;
 
259
        }
 
260
        return c*(t/=d)*t*((s+1)*t - s) + b;
 
261
    },
 
262
 
 
263
    /**
 
264
     * Overshoots end, then reverses and comes back to end.
 
265
     * @method backOut
 
266
     * @param {Number} t Time value used to compute current value
 
267
     * @param {Number} b Starting value
 
268
     * @param {Number} c Delta between start and end values
 
269
     * @param {Number} d Total length of animation
 
270
     * @param {Number} s Overshoot (optional)
 
271
     * @return {Number} The computed value for the current animation frame
 
272
     */
 
273
    backOut: function (t, b, c, d, s) {
 
274
        if (typeof s === 'undefined') {
 
275
            s = 1.70158;
 
276
        }
 
277
        return c*((t=t/d-1)*t*((s+1)*t + s) + 1) + b;
 
278
    },
 
279
    
 
280
    /**
 
281
     * Backtracks slightly, then reverses direction, overshoots end, 
 
282
     * then reverses and comes back to end.
 
283
     * @method backBoth
 
284
     * @param {Number} t Time value used to compute current value
 
285
     * @param {Number} b Starting value
 
286
     * @param {Number} c Delta between start and end values
 
287
     * @param {Number} d Total length of animation
 
288
     * @param {Number} s Overshoot (optional)
 
289
     * @return {Number} The computed value for the current animation frame
 
290
     */
 
291
    backBoth: function (t, b, c, d, s) {
 
292
        if (typeof s === 'undefined') {
 
293
            s = 1.70158; 
 
294
        }
 
295
        
 
296
        if ((t /= d/2 ) < 1) {
 
297
            return c/2*(t*t*(((s*=(1.525))+1)*t - s)) + b;
 
298
        }
 
299
        return c/2*((t-=2)*t*(((s*=(1.525))+1)*t + s) + 2) + b;
 
300
    },
 
301
 
 
302
    /**
 
303
     * Bounce off of start.
 
304
     * @method bounceIn
 
305
     * @param {Number} t Time value used to compute current value
 
306
     * @param {Number} b Starting value
 
307
     * @param {Number} c Delta between start and end values
 
308
     * @param {Number} d Total length of animation
 
309
     * @return {Number} The computed value for the current animation frame
 
310
     */
 
311
    bounceIn: function (t, b, c, d) {
 
312
        return c - Y.Easing.bounceOut(d-t, 0, c, d) + b;
 
313
    },
 
314
    
 
315
    /**
 
316
     * Bounces off end.
 
317
     * @method bounceOut
 
318
     * @param {Number} t Time value used to compute current value
 
319
     * @param {Number} b Starting value
 
320
     * @param {Number} c Delta between start and end values
 
321
     * @param {Number} d Total length of animation
 
322
     * @return {Number} The computed value for the current animation frame
 
323
     */
 
324
    bounceOut: function (t, b, c, d) {
 
325
        if ((t/=d) < (1/2.75)) {
 
326
                return c*(7.5625*t*t) + b;
 
327
        } else if (t < (2/2.75)) {
 
328
                return c*(7.5625*(t-=(1.5/2.75))*t + 0.75) + b;
 
329
        } else if (t < (2.5/2.75)) {
 
330
                return c*(7.5625*(t-=(2.25/2.75))*t + 0.9375) + b;
 
331
        }
 
332
        return c*(7.5625*(t-=(2.625/2.75))*t + 0.984375) + b;
 
333
    },
 
334
    
 
335
    /**
 
336
     * Bounces off start and end.
 
337
     * @method bounceBoth
 
338
     * @param {Number} t Time value used to compute current value
 
339
     * @param {Number} b Starting value
 
340
     * @param {Number} c Delta between start and end values
 
341
     * @param {Number} d Total length of animation
 
342
     * @return {Number} The computed value for the current animation frame
 
343
     */
 
344
    bounceBoth: function (t, b, c, d) {
 
345
        if (t < d/2) {
 
346
            return Y.Easing.bounceIn(t * 2, 0, c, d) * 0.5 + b;
 
347
        }
 
348
        return Y.Easing.bounceOut(t * 2 - d, 0, c, d) * 0.5 + c * 0.5 + b;
 
349
    }
 
350
};
 
351
 
 
352
 
 
353
}, '3.0.0pr1' ,{requires:['anim-base']});