1 if(!dojo._hasResource["dojox.fx.easing"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
2 dojo._hasResource["dojox.fx.easing"] = true;
3 dojo.provide("dojox.fx.easing");
5 dojox.fx.easing is in this little file so you don't need dojox.fx to utilize this.
6 dojox.fx has a lot of fun animations, but this module is optimized for size ...
10 // summary: Collection of easing functions to use beyond the default dojo._defaultEasing
13 // Easing functions are used to manipulate the iteration through
14 // an _Animation's _Line. _Line being the properties of an Animation,
15 // and the easing function progresses through that Line determing
16 // how quickly (or slowly) it should go. Or more accurately: modify
17 // the value of the _Line based on the percentage of animation completed.
20 // | dojo.require("dojox.fx.easing");
21 // | var anim = dojo.fadeOut({
24 // | easing: dojox.fx.easing.quadIn
28 linear: function(/* Decimal? */n){
29 // summary: A linear easing function
33 quadIn: function(/* Decimal? */n){
34 return Math.pow(n, 2);
37 quadOut: function(/* Decimal? */n){
38 return n * (n-2) * -1;
41 quadInOut: function(/* Decimal? */n){
43 if(n<1){ return Math.pow(n, 2) / 2; }
44 return -1 * ((--n)*(n-2) - 1) / 2;
47 cubicIn: function(/* Decimal? */n){
48 return Math.pow(n, 3);
51 cubicOut: function(/* Decimal? */n){
52 return Math.pow(n-1, 3) + 1;
55 cubicInOut: function(/* Decimal? */n){
57 if(n<1){ return Math.pow(n, 3) / 2; }
59 return (Math.pow(n, 3) + 2) / 2;
62 quartIn: function(/* Decimal? */n){
63 return Math.pow(n, 4);
66 quartOut: function(/* Decimal? */n){
67 return -1 * (Math.pow(n-1, 4) - 1);
70 quartInOut: function(/* Decimal? */n){
72 if(n<1){ return Math.pow(n, 4) / 2; }
74 return -1/2 * (Math.pow(n, 4) - 2);
77 quintIn: function(/* Decimal? */n){
78 return Math.pow(n, 5);
81 quintOut: function(/* Decimal? */n){
82 return Math.pow(n-1, 5) + 1;
85 quintInOut: function(/* Decimal? */n){
87 if(n<1){ return Math.pow(n, 5) / 2; };
89 return (Math.pow(n, 5) + 2) / 2;
92 sineIn: function(/* Decimal? */n){
93 return -1 * Math.cos(n * (Math.PI/2)) + 1;
96 sineOut: function(/* Decimal? */n){
97 return Math.sin(n * (Math.PI/2));
100 sineInOut: function(/* Decimal? */n){
101 return -1 * (Math.cos(Math.PI*n) - 1) / 2;
104 expoIn: function(/* Decimal? */n){
105 return (n==0) ? 0 : Math.pow(2, 10 * (n - 1));
108 expoOut: function(/* Decimal? */n){
109 return (n==1) ? 1 : (-1 * Math.pow(2, -10 * n) + 1);
112 expoInOut: function(/* Decimal? */n){
113 if(n==0){ return 0; }
114 if(n==1){ return 1; }
116 if(n<1){ return Math.pow(2, 10 * (n-1)) / 2; }
118 return (-1 * Math.pow(2, -10 * n) + 2) / 2;
121 circIn: function(/* Decimal? */n){
122 return -1 * (Math.sqrt(1 - Math.pow(n, 2)) - 1);
125 circOut: function(/* Decimal? */n){
127 return Math.sqrt(1 - Math.pow(n, 2));
130 circInOut: function(/* Decimal? */n){
132 if(n<1){ return -1/2 * (Math.sqrt(1 - Math.pow(n, 2)) - 1); }
134 return 1/2 * (Math.sqrt(1 - Math.pow(n, 2)) + 1);
137 backIn: function(/* Decimal? */n){
139 return Math.pow(n, 2) * ((s+1)*n - s);
142 backOut: function(/* Decimal? */n){
143 // summary: an easing function that pops past the range briefly, and
144 // slowly comes back.
147 return Math.pow(n, 2) * ((s + 1) * n + s) + 1;
150 backInOut: function(/* Decimal? */n){
151 var s = 1.70158 * 1.525;
153 if(n < 1){ return (Math.pow(n, 2)*((s+1)*n - s))/2; }
155 return (Math.pow(n, 2)*((s+1)*n + s) + 2)/2;
158 elasticIn: function(/* Decimal? */n){
159 if(n==0){ return 0; }
160 if(n==1){ return 1; }
164 return -1 * Math.pow(2,10*n) * Math.sin((n-s)*(2*Math.PI)/p);
167 elasticOut: function(/* Decimal? */n){
168 // summary: An easing function that elasticly snaps around the target value, near the end of the Animation
173 return Math.pow(2,-10*n) * Math.sin((n-s)*(2*Math.PI)/p) + 1;
176 elasticInOut: function(/* Decimal? */n){
177 // summary: An easing function that elasticly snaps around the value, near the beginning and end of the Animation
185 return -.5*(Math.pow(2,10*n) * Math.sin((n-s)*(2*Math.PI)/p));
188 return .5*(Math.pow(2,-10*n) * Math.sin((n-s)*(2*Math.PI)/p)) + 1;
191 bounceIn: function(/* Decimal? */n){
192 // summary: An easing function that "bounces" near the beginning of an Animation
193 return (1 - dojox.fx.easing.bounceOut(1-n)); // Decimal
196 bounceOut: function(/* Decimal? */n){
197 // summary: An easing function that "bounces" near the end of an Animation
202 l = s*Math.pow(n, 2);
203 }else if(n < (2 / p)){
205 l = s * Math.pow(n, 2) + .75;
206 }else if(n < (2.5 / p)){
208 l = s * Math.pow(n, 2) + .9375;
211 l = s * Math.pow(n, 2) + .984375;
216 bounceInOut: function(/* Decimal? */n){
217 // summary: An easing function that "bounces" at the beginning and end of the Animation
218 if(n<0.5){ return dojox.fx.easing.bounceIn(n*2) / 2; }
219 return (dojox.fx.easing.bounceOut(n*2-1) / 2) + 0.5; // Decimal