]> git.wh0rd.org - tt-rss.git/blob - lib/dojo/fx/easing.js
add dijit/dojo stuff; initial ui mockup
[tt-rss.git] / lib / dojo / fx / easing.js
1 /*
2 Copyright (c) 2004-2010, The Dojo Foundation All Rights Reserved.
3 Available via Academic Free License >= 2.1 OR the modified BSD license.
4 see: http://dojotoolkit.org/license for details
5 */
6
7
8 if(!dojo._hasResource["dojo.fx.easing"]){
9 dojo._hasResource["dojo.fx.easing"]=true;
10 dojo.provide("dojo.fx.easing");
11 dojo.fx.easing={linear:function(n){
12 return n;
13 },quadIn:function(n){
14 return Math.pow(n,2);
15 },quadOut:function(n){
16 return n*(n-2)*-1;
17 },quadInOut:function(n){
18 n=n*2;
19 if(n<1){
20 return Math.pow(n,2)/2;
21 }
22 return -1*((--n)*(n-2)-1)/2;
23 },cubicIn:function(n){
24 return Math.pow(n,3);
25 },cubicOut:function(n){
26 return Math.pow(n-1,3)+1;
27 },cubicInOut:function(n){
28 n=n*2;
29 if(n<1){
30 return Math.pow(n,3)/2;
31 }
32 n-=2;
33 return (Math.pow(n,3)+2)/2;
34 },quartIn:function(n){
35 return Math.pow(n,4);
36 },quartOut:function(n){
37 return -1*(Math.pow(n-1,4)-1);
38 },quartInOut:function(n){
39 n=n*2;
40 if(n<1){
41 return Math.pow(n,4)/2;
42 }
43 n-=2;
44 return -1/2*(Math.pow(n,4)-2);
45 },quintIn:function(n){
46 return Math.pow(n,5);
47 },quintOut:function(n){
48 return Math.pow(n-1,5)+1;
49 },quintInOut:function(n){
50 n=n*2;
51 if(n<1){
52 return Math.pow(n,5)/2;
53 }
54 n-=2;
55 return (Math.pow(n,5)+2)/2;
56 },sineIn:function(n){
57 return -1*Math.cos(n*(Math.PI/2))+1;
58 },sineOut:function(n){
59 return Math.sin(n*(Math.PI/2));
60 },sineInOut:function(n){
61 return -1*(Math.cos(Math.PI*n)-1)/2;
62 },expoIn:function(n){
63 return (n==0)?0:Math.pow(2,10*(n-1));
64 },expoOut:function(n){
65 return (n==1)?1:(-1*Math.pow(2,-10*n)+1);
66 },expoInOut:function(n){
67 if(n==0){
68 return 0;
69 }
70 if(n==1){
71 return 1;
72 }
73 n=n*2;
74 if(n<1){
75 return Math.pow(2,10*(n-1))/2;
76 }
77 --n;
78 return (-1*Math.pow(2,-10*n)+2)/2;
79 },circIn:function(n){
80 return -1*(Math.sqrt(1-Math.pow(n,2))-1);
81 },circOut:function(n){
82 n=n-1;
83 return Math.sqrt(1-Math.pow(n,2));
84 },circInOut:function(n){
85 n=n*2;
86 if(n<1){
87 return -1/2*(Math.sqrt(1-Math.pow(n,2))-1);
88 }
89 n-=2;
90 return 1/2*(Math.sqrt(1-Math.pow(n,2))+1);
91 },backIn:function(n){
92 var s=1.70158;
93 return Math.pow(n,2)*((s+1)*n-s);
94 },backOut:function(n){
95 n=n-1;
96 var s=1.70158;
97 return Math.pow(n,2)*((s+1)*n+s)+1;
98 },backInOut:function(n){
99 var s=1.70158*1.525;
100 n=n*2;
101 if(n<1){
102 return (Math.pow(n,2)*((s+1)*n-s))/2;
103 }
104 n-=2;
105 return (Math.pow(n,2)*((s+1)*n+s)+2)/2;
106 },elasticIn:function(n){
107 if(n==0||n==1){
108 return n;
109 }
110 var p=0.3;
111 var s=p/4;
112 n=n-1;
113 return -1*Math.pow(2,10*n)*Math.sin((n-s)*(2*Math.PI)/p);
114 },elasticOut:function(n){
115 if(n==0||n==1){
116 return n;
117 }
118 var p=0.3;
119 var s=p/4;
120 return Math.pow(2,-10*n)*Math.sin((n-s)*(2*Math.PI)/p)+1;
121 },elasticInOut:function(n){
122 if(n==0){
123 return 0;
124 }
125 n=n*2;
126 if(n==2){
127 return 1;
128 }
129 var p=0.3*1.5;
130 var s=p/4;
131 if(n<1){
132 n-=1;
133 return -0.5*(Math.pow(2,10*n)*Math.sin((n-s)*(2*Math.PI)/p));
134 }
135 n-=1;
136 return 0.5*(Math.pow(2,-10*n)*Math.sin((n-s)*(2*Math.PI)/p))+1;
137 },bounceIn:function(n){
138 return (1-dojo.fx.easing.bounceOut(1-n));
139 },bounceOut:function(n){
140 var s=7.5625;
141 var p=2.75;
142 var l;
143 if(n<(1/p)){
144 l=s*Math.pow(n,2);
145 }else{
146 if(n<(2/p)){
147 n-=(1.5/p);
148 l=s*Math.pow(n,2)+0.75;
149 }else{
150 if(n<(2.5/p)){
151 n-=(2.25/p);
152 l=s*Math.pow(n,2)+0.9375;
153 }else{
154 n-=(2.625/p);
155 l=s*Math.pow(n,2)+0.984375;
156 }
157 }
158 }
159 return l;
160 },bounceInOut:function(n){
161 if(n<0.5){
162 return dojo.fx.easing.bounceIn(n*2)/2;
163 }
164 return (dojo.fx.easing.bounceOut(n*2-1)/2)+0.5;
165 }};
166 }