|
1 /* |
|
2 |
|
3 * jQuery Easing v1.3 - http://gsgd.co.uk/sandbox/jquery/easing/ |
|
4 |
|
5 * |
|
6 |
|
7 * Uses the built in easing capabilities added In jQuery 1.1 |
|
8 |
|
9 * to offer multiple easing options |
|
10 |
|
11 * |
|
12 |
|
13 * TERMS OF USE - jQuery Easing |
|
14 |
|
15 * |
|
16 |
|
17 * Open source under the BSD License. |
|
18 |
|
19 * |
|
20 |
|
21 * Copyright © 2008 George McGinley Smith |
|
22 |
|
23 * All rights reserved. |
|
24 |
|
25 * |
|
26 |
|
27 * Redistribution and use in source and binary forms, with or without modification, |
|
28 |
|
29 * are permitted provided that the following conditions are met: |
|
30 |
|
31 * |
|
32 |
|
33 * Redistributions of source code must retain the above copyright notice, this list of |
|
34 |
|
35 * conditions and the following disclaimer. |
|
36 |
|
37 * Redistributions in binary form must reproduce the above copyright notice, this list |
|
38 |
|
39 * of conditions and the following disclaimer in the documentation and/or other materials |
|
40 |
|
41 * provided with the distribution. |
|
42 |
|
43 * |
|
44 |
|
45 * Neither the name of the author nor the names of contributors may be used to endorse |
|
46 |
|
47 * or promote products derived from this software without specific prior written permission. |
|
48 |
|
49 * |
|
50 |
|
51 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY |
|
52 |
|
53 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF |
|
54 |
|
55 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE |
|
56 |
|
57 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
|
58 |
|
59 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE |
|
60 |
|
61 * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED |
|
62 |
|
63 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING |
|
64 |
|
65 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED |
|
66 |
|
67 * OF THE POSSIBILITY OF SUCH DAMAGE. |
|
68 |
|
69 * |
|
70 |
|
71 */ |
|
72 |
|
73 |
|
74 |
|
75 // t: current time, b: begInnIng value, c: change In value, d: duration |
|
76 |
|
77 jQuery.easing['jswing'] = jQuery.easing['swing']; |
|
78 |
|
79 |
|
80 |
|
81 jQuery.extend( jQuery.easing, |
|
82 |
|
83 { |
|
84 |
|
85 def: 'easeOutQuad', |
|
86 |
|
87 swing: function (x, t, b, c, d) { |
|
88 |
|
89 //alert(jQuery.easing.default); |
|
90 |
|
91 return jQuery.easing[jQuery.easing.def](x, t, b, c, d); |
|
92 |
|
93 }, |
|
94 |
|
95 easeInQuad: function (x, t, b, c, d) { |
|
96 |
|
97 return c*(t/=d)*t + b; |
|
98 |
|
99 }, |
|
100 |
|
101 easeOutQuad: function (x, t, b, c, d) { |
|
102 |
|
103 return -c *(t/=d)*(t-2) + b; |
|
104 |
|
105 }, |
|
106 |
|
107 easeInOutQuad: function (x, t, b, c, d) { |
|
108 |
|
109 if ((t/=d/2) < 1) return c/2*t*t + b; |
|
110 |
|
111 return -c/2 * ((--t)*(t-2) - 1) + b; |
|
112 |
|
113 }, |
|
114 |
|
115 easeInCubic: function (x, t, b, c, d) { |
|
116 |
|
117 return c*(t/=d)*t*t + b; |
|
118 |
|
119 }, |
|
120 |
|
121 easeOutCubic: function (x, t, b, c, d) { |
|
122 |
|
123 return c*((t=t/d-1)*t*t + 1) + b; |
|
124 |
|
125 }, |
|
126 |
|
127 easeInOutCubic: function (x, t, b, c, d) { |
|
128 |
|
129 if ((t/=d/2) < 1) return c/2*t*t*t + b; |
|
130 |
|
131 return c/2*((t-=2)*t*t + 2) + b; |
|
132 |
|
133 }, |
|
134 |
|
135 easeInQuart: function (x, t, b, c, d) { |
|
136 |
|
137 return c*(t/=d)*t*t*t + b; |
|
138 |
|
139 }, |
|
140 |
|
141 easeOutQuart: function (x, t, b, c, d) { |
|
142 |
|
143 return -c * ((t=t/d-1)*t*t*t - 1) + b; |
|
144 |
|
145 }, |
|
146 |
|
147 easeInOutQuart: function (x, t, b, c, d) { |
|
148 |
|
149 if ((t/=d/2) < 1) return c/2*t*t*t*t + b; |
|
150 |
|
151 return -c/2 * ((t-=2)*t*t*t - 2) + b; |
|
152 |
|
153 }, |
|
154 |
|
155 easeInQuint: function (x, t, b, c, d) { |
|
156 |
|
157 return c*(t/=d)*t*t*t*t + b; |
|
158 |
|
159 }, |
|
160 |
|
161 easeOutQuint: function (x, t, b, c, d) { |
|
162 |
|
163 return c*((t=t/d-1)*t*t*t*t + 1) + b; |
|
164 |
|
165 }, |
|
166 |
|
167 easeInOutQuint: function (x, t, b, c, d) { |
|
168 |
|
169 if ((t/=d/2) < 1) return c/2*t*t*t*t*t + b; |
|
170 |
|
171 return c/2*((t-=2)*t*t*t*t + 2) + b; |
|
172 |
|
173 }, |
|
174 |
|
175 easeInSine: function (x, t, b, c, d) { |
|
176 |
|
177 return -c * Math.cos(t/d * (Math.PI/2)) + c + b; |
|
178 |
|
179 }, |
|
180 |
|
181 easeOutSine: function (x, t, b, c, d) { |
|
182 |
|
183 return c * Math.sin(t/d * (Math.PI/2)) + b; |
|
184 |
|
185 }, |
|
186 |
|
187 easeInOutSine: function (x, t, b, c, d) { |
|
188 |
|
189 return -c/2 * (Math.cos(Math.PI*t/d) - 1) + b; |
|
190 |
|
191 }, |
|
192 |
|
193 easeInExpo: function (x, t, b, c, d) { |
|
194 |
|
195 return (t==0) ? b : c * Math.pow(2, 10 * (t/d - 1)) + b; |
|
196 |
|
197 }, |
|
198 |
|
199 easeOutExpo: function (x, t, b, c, d) { |
|
200 |
|
201 return (t==d) ? b+c : c * (-Math.pow(2, -10 * t/d) + 1) + b; |
|
202 |
|
203 }, |
|
204 |
|
205 easeInOutExpo: function (x, t, b, c, d) { |
|
206 |
|
207 if (t==0) return b; |
|
208 |
|
209 if (t==d) return b+c; |
|
210 |
|
211 if ((t/=d/2) < 1) return c/2 * Math.pow(2, 10 * (t - 1)) + b; |
|
212 |
|
213 return c/2 * (-Math.pow(2, -10 * --t) + 2) + b; |
|
214 |
|
215 }, |
|
216 |
|
217 easeInCirc: function (x, t, b, c, d) { |
|
218 |
|
219 return -c * (Math.sqrt(1 - (t/=d)*t) - 1) + b; |
|
220 |
|
221 }, |
|
222 |
|
223 easeOutCirc: function (x, t, b, c, d) { |
|
224 |
|
225 return c * Math.sqrt(1 - (t=t/d-1)*t) + b; |
|
226 |
|
227 }, |
|
228 |
|
229 easeInOutCirc: function (x, t, b, c, d) { |
|
230 |
|
231 if ((t/=d/2) < 1) return -c/2 * (Math.sqrt(1 - t*t) - 1) + b; |
|
232 |
|
233 return c/2 * (Math.sqrt(1 - (t-=2)*t) + 1) + b; |
|
234 |
|
235 }, |
|
236 |
|
237 easeInElastic: function (x, t, b, c, d) { |
|
238 |
|
239 var s=1.70158;var p=0;var a=c; |
|
240 |
|
241 if (t==0) return b; if ((t/=d)==1) return b+c; if (!p) p=d*.3; |
|
242 |
|
243 if (a < Math.abs(c)) { a=c; var s=p/4; } |
|
244 |
|
245 else var s = p/(2*Math.PI) * Math.asin (c/a); |
|
246 |
|
247 return -(a*Math.pow(2,10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )) + b; |
|
248 |
|
249 }, |
|
250 |
|
251 easeOutElastic: function (x, t, b, c, d) { |
|
252 |
|
253 var s=1.70158;var p=0;var a=c; |
|
254 |
|
255 if (t==0) return b; if ((t/=d)==1) return b+c; if (!p) p=d*.3; |
|
256 |
|
257 if (a < Math.abs(c)) { a=c; var s=p/4; } |
|
258 |
|
259 else var s = p/(2*Math.PI) * Math.asin (c/a); |
|
260 |
|
261 return a*Math.pow(2,-10*t) * Math.sin( (t*d-s)*(2*Math.PI)/p ) + c + b; |
|
262 |
|
263 }, |
|
264 |
|
265 easeInOutElastic: function (x, t, b, c, d) { |
|
266 |
|
267 var s=1.70158;var p=0;var a=c; |
|
268 |
|
269 if (t==0) return b; if ((t/=d/2)==2) return b+c; if (!p) p=d*(.3*1.5); |
|
270 |
|
271 if (a < Math.abs(c)) { a=c; var s=p/4; } |
|
272 |
|
273 else var s = p/(2*Math.PI) * Math.asin (c/a); |
|
274 |
|
275 if (t < 1) return -.5*(a*Math.pow(2,10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )) + b; |
|
276 |
|
277 return a*Math.pow(2,-10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )*.5 + c + b; |
|
278 |
|
279 }, |
|
280 |
|
281 easeInBack: function (x, t, b, c, d, s) { |
|
282 |
|
283 if (s == undefined) s = 1.70158; |
|
284 |
|
285 return c*(t/=d)*t*((s+1)*t - s) + b; |
|
286 |
|
287 }, |
|
288 |
|
289 easeOutBack: function (x, t, b, c, d, s) { |
|
290 |
|
291 if (s == undefined) s = 1.70158; |
|
292 |
|
293 return c*((t=t/d-1)*t*((s+1)*t + s) + 1) + b; |
|
294 |
|
295 }, |
|
296 |
|
297 easeInOutBack: function (x, t, b, c, d, s) { |
|
298 |
|
299 if (s == undefined) s = 1.70158; |
|
300 |
|
301 if ((t/=d/2) < 1) return c/2*(t*t*(((s*=(1.525))+1)*t - s)) + b; |
|
302 |
|
303 return c/2*((t-=2)*t*(((s*=(1.525))+1)*t + s) + 2) + b; |
|
304 |
|
305 }, |
|
306 |
|
307 easeInBounce: function (x, t, b, c, d) { |
|
308 |
|
309 return c - jQuery.easing.easeOutBounce (x, d-t, 0, c, d) + b; |
|
310 |
|
311 }, |
|
312 |
|
313 easeOutBounce: function (x, t, b, c, d) { |
|
314 |
|
315 if ((t/=d) < (1/2.75)) { |
|
316 |
|
317 return c*(7.5625*t*t) + b; |
|
318 |
|
319 } else if (t < (2/2.75)) { |
|
320 |
|
321 return c*(7.5625*(t-=(1.5/2.75))*t + .75) + b; |
|
322 |
|
323 } else if (t < (2.5/2.75)) { |
|
324 |
|
325 return c*(7.5625*(t-=(2.25/2.75))*t + .9375) + b; |
|
326 |
|
327 } else { |
|
328 |
|
329 return c*(7.5625*(t-=(2.625/2.75))*t + .984375) + b; |
|
330 |
|
331 } |
|
332 |
|
333 }, |
|
334 |
|
335 easeInOutBounce: function (x, t, b, c, d) { |
|
336 |
|
337 if (t < d/2) return jQuery.easing.easeInBounce (x, t*2, 0, c, d) * .5 + b; |
|
338 |
|
339 return jQuery.easing.easeOutBounce (x, t*2-d, 0, c, d) * .5 + c*.5 + b; |
|
340 |
|
341 } |
|
342 |
|
343 }); |
|
344 |
|
345 |
|
346 |
|
347 /* |
|
348 |
|
349 * |
|
350 |
|
351 * TERMS OF USE - EASING EQUATIONS |
|
352 |
|
353 * |
|
354 |
|
355 * Open source under the BSD License. |
|
356 |
|
357 * |
|
358 |
|
359 * Copyright © 2001 Robert Penner |
|
360 |
|
361 * All rights reserved. |
|
362 |
|
363 * |
|
364 |
|
365 * Redistribution and use in source and binary forms, with or without modification, |
|
366 |
|
367 * are permitted provided that the following conditions are met: |
|
368 |
|
369 * |
|
370 |
|
371 * Redistributions of source code must retain the above copyright notice, this list of |
|
372 |
|
373 * conditions and the following disclaimer. |
|
374 |
|
375 * Redistributions in binary form must reproduce the above copyright notice, this list |
|
376 |
|
377 * of conditions and the following disclaimer in the documentation and/or other materials |
|
378 |
|
379 * provided with the distribution. |
|
380 |
|
381 * |
|
382 |
|
383 * Neither the name of the author nor the names of contributors may be used to endorse |
|
384 |
|
385 * or promote products derived from this software without specific prior written permission. |
|
386 |
|
387 * |
|
388 |
|
389 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY |
|
390 |
|
391 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF |
|
392 |
|
393 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE |
|
394 |
|
395 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
|
396 |
|
397 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE |
|
398 |
|
399 * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED |
|
400 |
|
401 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING |
|
402 |
|
403 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED |
|
404 |
|
405 * OF THE POSSIBILITY OF SUCH DAMAGE. |
|
406 |
|
407 * |
|
408 |
|
409 */ |