2 * Interface Elements for jQuery
\r
5 * http://interface.eyecon.ro
\r
7 * Copyright (c) 2006 Stefan Petre
\r
8 * Dual licensed under the MIT (MIT-LICENSE.txt)
\r
9 * and GPL (GPL-LICENSE.txt) licenses.
\r
13 * Starting with jQuery 1.1 the fx function accepts easing formulas that can be used with .animation() and most of FX plugins from Interface. The object can be extended to accept new easing formulas
\r
19 * @param Integer p period step in animation
\r
20 * @param Integer n current time
\r
21 * @param Mixed firstNum begin value
\r
22 * @param Mixed delta change in
\r
23 * @param Integer duration duration
\r
26 linear: function(p, n, firstNum, delta, duration) {
\r
27 return ((-Math.cos(p*Math.PI)/2) + 0.5) * delta + firstNum;
\r
30 easein: function(p, n, firstNum, delta, duration) {
\r
31 return delta*(n/=duration)*n*n + firstNum;
\r
34 easeout: function(p, n, firstNum, delta, duration) {
\r
35 return -delta * ((n=n/duration-1)*n*n*n - 1) + firstNum;
\r
38 easeboth: function(p, n, firstNum, delta, duration) {
\r
39 if ((n/=duration/2) < 1)
\r
40 return delta/2*n*n*n*n + firstNum;
\r
41 return -delta/2 * ((n-=2)*n*n*n - 2) + firstNum;
\r
44 bounceout: function(p, n, firstNum, delta, duration) {
\r
45 if ((n/=duration) < (1/2.75)) {
\r
46 return delta*(7.5625*n*n) + firstNum;
\r
47 } else if (n < (2/2.75)) {
\r
48 return delta*(7.5625*(n-=(1.5/2.75))*n + .75) + firstNum;
\r
49 } else if (n < (2.5/2.75)) {
\r
50 return delta*(7.5625*(n-=(2.25/2.75))*n + .9375) + firstNum;
\r
52 return delta*(7.5625*(n-=(2.625/2.75))*n + .984375) + firstNum;
\r
56 bouncein: function(p, n, firstNum, delta, duration) {
\r
57 if (jQuery.easing.bounceout)
\r
58 return delta - jQuery.easing.bounceout (p, duration - n, 0, delta, duration) + firstNum;
\r
59 return firstNum + delta;
\r
62 bounceboth: function(p, n, firstNum, delta, duration) {
\r
63 if (jQuery.easing.bouncein && jQuery.easing.bounceout)
\r
65 return jQuery.easing.bouncein(p, n*2, 0, delta, duration) * .5 + firstNum;
\r
66 return jQuery.easing.bounceout(p, n*2-duration, 0, delta, duration) * .5 + delta*.5 + firstNum;
\r
67 return firstNum + delta;
\r
70 elasticin: function(p, n, firstNum, delta, duration) {
\r
74 if ((n/=duration)==1)
\r
75 return firstNum+delta;
\r
78 if (a < Math.abs(delta)) {
\r
82 s = p/(2*Math.PI) * Math.asin (delta/a);
\r
84 return -(a*Math.pow(2,10*(n-=1)) * Math.sin( (n*duration-s)*(2*Math.PI)/p )) + firstNum;
\r
87 elasticout:function(p, n, firstNum, delta, duration) {
\r
91 if ((n/=duration/2)==2)
\r
92 return firstNum + delta;
\r
95 if (a < Math.abs(delta)){
\r
99 s = p/(2*Math.PI) * Math.asin (delta/a);
\r
101 return a*Math.pow(2,-10*n) * Math.sin( (n*duration-s)*(2*Math.PI)/p ) + delta + firstNum;
\r
104 elasticboth: function(p, n, firstNum, delta, duration) {
\r
108 if ((n/=duration/2)==2)
\r
109 return firstNum + delta;
\r
112 if (a < Math.abs(delta)){
\r
116 s = p/(2*Math.PI) * Math.asin (delta/a);
\r
119 return -.5*(a*Math.pow(2,10*(n-=1)) * Math.sin( (n*duration-s)*(2*Math.PI)/p )) + firstNum;
\r
121 return a*Math.pow(2,-10*(n-=1)) * Math.sin( (n*duration-s)*(2*Math.PI)/p )*.5 + delta + firstNum;
\r