8 var FI_BOTTOM = 2; |
8 var FI_BOTTOM = 2; |
9 var FI_IN = 1; |
9 var FI_IN = 1; |
10 var FI_OUT = 2; |
10 var FI_OUT = 2; |
11 var FI_UP = 1; |
11 var FI_UP = 1; |
12 var FI_DOWN = 2; |
12 var FI_DOWN = 2; |
|
13 |
|
14 /** |
|
15 * You can thank Robert Penner for the math used here. Ported from an ActionScript class. |
|
16 * License: Modified BSD license <http://www.robertpenner.com/easing_terms_of_use.html> |
|
17 */ |
|
18 |
|
19 // Effects code - don't bother changing these formulas |
|
20 var Back = { |
|
21 easeOut: function(t, b, c, d, s) |
|
22 { |
|
23 if (s == undefined) s = 1.70158; |
|
24 return c * ( ( t=t/d-1 ) * t * ( ( s + 1 ) * t + s) + 1) + b; |
|
25 }, |
|
26 easeIn: function (t, b, c, d, s) |
|
27 { |
|
28 if (s == undefined) s = 1.70158; |
|
29 return c * ( t/=d ) * t * ( ( s + 1 ) * t - s) + b; |
|
30 }, |
|
31 easeInOut: function (t, b, c, d, s) |
|
32 { |
|
33 if (s == undefined) s = 1.70158; |
|
34 if ((t /= d/2) < 1) |
|
35 { |
|
36 return c/2*(t*t*(((s*=(1.525))+1)*t - s)) + b; |
|
37 } |
|
38 return c/2*((t-=2)*t*(((s*=(1.525))+1)*t + s) + 2) + b; |
|
39 } |
|
40 } |
|
41 |
|
42 // This should be set to the class name of the effect you want. |
|
43 var GlideEffect = Back; |
13 |
44 |
14 // Placeholder functions, to make organization a little easier :-) |
45 // Placeholder functions, to make organization a little easier :-) |
15 |
46 |
16 function fly_in_top(element, nofade, height_taken_care_of) |
47 function fly_in_top(element, nofade, height_taken_care_of) |
17 { |
48 { |
89 top = h + y; |
120 top = h + y; |
90 } |
121 } |
91 |
122 |
92 var abs_dir = ( ( origin == FI_TOP && direction == FI_IN ) || ( origin == FI_BOTTOM && direction == FI_OUT ) ) ? FI_DOWN : FI_UP; |
123 var abs_dir = ( ( origin == FI_TOP && direction == FI_IN ) || ( origin == FI_BOTTOM && direction == FI_OUT ) ) ? FI_DOWN : FI_UP; |
93 |
124 |
|
125 var diff_top = top - topi; |
|
126 var diff_left = left - lefti; |
|
127 |
|
128 var frames = 100; |
|
129 var timeout = 0; |
|
130 var timerstep = 8; |
|
131 |
|
132 // cache element so it can be changed from within setTimeout() |
|
133 var rand_seed = Math.floor(Math.random() * 1000000); |
|
134 fly_in_cache[rand_seed] = element; |
|
135 |
|
136 for ( var i = 0; i < frames; i++ ) |
|
137 { |
|
138 topc = GlideEffect.easeInOut(i, topi, diff_top, frames); |
|
139 leftc = GlideEffect.easeInOut(i, lefti, diff_left, frames); |
|
140 setTimeout('var o = fly_in_cache['+rand_seed+']; o.style.top=\''+topc+'px\'; o.style.left=\''+leftc+'px\';', timeout); |
|
141 timeout += timerstep; |
|
142 |
|
143 var ratio = i / frames; |
|
144 |
|
145 if ( !nofade ) |
|
146 { |
|
147 // handle fade |
|
148 var opac_factor = ratio * 100; |
|
149 if ( direction == FI_OUT ) |
|
150 opac_factor = 100 - opac_factor; |
|
151 setTimeout('var o = fly_in_cache['+rand_seed+']; domObjChangeOpac('+opac_factor+', o);', timeout); |
|
152 } |
|
153 |
|
154 } |
|
155 |
94 /* |
156 /* |
95 * Framestepper parameters |
157 * Framestepper parameters |
96 */ |
158 * / |
97 |
159 |
98 // starting value for inertia |
160 // starting value for inertia |
99 var inertiabase = 1; |
161 var inertiabase = 1; |
100 // increment for inertia, or 0 to disable inertia effects |
162 // increment for inertia, or 0 to disable inertia effects |
101 var inertiainc = 1; |
163 var inertiainc = 1; |
119 var rand_seed = Math.floor(Math.random() * 1000000); |
181 var rand_seed = Math.floor(Math.random() * 1000000); |
120 fly_in_cache[rand_seed] = element; |
182 fly_in_cache[rand_seed] = element; |
121 |
183 |
122 // set element left pos, you can comment this out to preserve left position |
184 // set element left pos, you can comment this out to preserve left position |
123 element.style.left = left + 'px'; |
185 element.style.left = left + 'px'; |
124 element.style.top = topi + 'px'; |
|
125 |
|
126 if ( nofade ) |
|
127 { |
|
128 domObjChangeOpac(100, element); |
|
129 } |
|
130 |
186 |
131 // total distance to be traveled |
187 // total distance to be traveled |
132 dist = abs(top - topi); |
188 dist = abs(top - topi); |
133 |
189 |
134 // animation loop |
190 // animation loop |