includes/clientside/static/flyin.js
changeset 81 d7fc25acd3f3
parent 74 68469a95658d
child 420 301f546688d1
equal deleted inserted replaced
80:cb7dde69c301 81:d7fc25acd3f3
   155       setTimeout('var o = fly_in_cache['+rand_seed+']; domObjChangeOpac('+opac_factor+', o);', timeout);
   155       setTimeout('var o = fly_in_cache['+rand_seed+']; domObjChangeOpac('+opac_factor+', o);', timeout);
   156     }
   156     }
   157     
   157     
   158   }
   158   }
   159   
   159   
   160   /*
   160   // old framestepper code removed from here in Loch Ness
   161    * Framestepper parameters
       
   162    * /
       
   163   
   161   
   164   // starting value for inertia
       
   165   var inertiabase = 1;
       
   166   // increment for inertia, or 0 to disable inertia effects
       
   167   var inertiainc  = 1;
       
   168   // when the progress reaches this %, deceleration is activated
       
   169   var divider = 0.666667;
       
   170   // multiplier for deceleration, setting this above 2 can cause some weird slowdown effects
       
   171   var decelerate  = 2; // 1 / divider; // reciprocal of the divider
       
   172   
       
   173   /*
       
   174    * Timer parameters
       
   175    * /
       
   176   
       
   177   // how long animation start is delayed, you want this at 0
       
   178   var timer = 0;
       
   179   // frame ttl
       
   180   var timestep = 12;
       
   181   // sanity check
       
   182   var frames = 0;
       
   183   
       
   184   // cache element so it can be changed from within setTimeout()
       
   185   var rand_seed = Math.floor(Math.random() * 1000000);
       
   186   fly_in_cache[rand_seed] = element;
       
   187   
       
   188   // set element left pos, you can comment this out to preserve left position
       
   189   element.style.left = left + 'px';
       
   190   
       
   191   // total distance to be traveled
       
   192   dist = abs(top - topi);
       
   193   
       
   194   // animation loop
       
   195   
       
   196   while ( true )
       
   197   {
       
   198     // used for a sanity check
       
   199     frames++;
       
   200     
       
   201     // time until this frame should be executed
       
   202     timer += timestep;
       
   203     
       
   204     // math stuff
       
   205     // how far we are along in animation...
       
   206     diff = abs(top - topi);
       
   207     // ...in %
       
   208     ratio = abs( 1 - ( diff / dist ) );
       
   209     // decelerate if we're more than 2/3 of the way there
       
   210     if ( ratio < divider )
       
   211       inertiabase += inertiainc;
       
   212     else
       
   213       inertiabase -= ( inertiainc * decelerate );
       
   214     
       
   215     // if the deceleration factor is anywhere above 1 then technically that can cause an infinite loop
       
   216     // so leave this in there unless decelerate is set to 1
       
   217     if ( inertiabase < 1 )
       
   218       inertiabase = 1;
       
   219     
       
   220     // uncomment to disable inertia
       
   221     // inertiabase = 3;
       
   222     
       
   223     // figure out frame Y position
       
   224     topi = ( abs_dir == FI_UP ) ? topi - inertiabase : topi + inertiabase;
       
   225     if ( ( abs_dir == FI_DOWN && topi > top ) || ( abs_dir == FI_UP && top > topi ) )
       
   226       topi = top;
       
   227     
       
   228     // tell the browser to do it
       
   229     setTimeout('var o = fly_in_cache['+rand_seed+']; o.style.top=\''+topi+'px\';', timer);
       
   230     if ( !nofade )
       
   231     {
       
   232       // handle fade
       
   233       opac_factor = ratio * 100;
       
   234       if ( direction == FI_OUT )
       
   235         opac_factor = 100 - opac_factor;
       
   236       setTimeout('var o = fly_in_cache['+rand_seed+']; domObjChangeOpac('+opac_factor+', o);', timer);
       
   237     }
       
   238     
       
   239     // if we're done or if our sanity check failed then break out of the loop
       
   240     if ( ( abs_dir == FI_DOWN && topi >= top ) || ( abs_dir == FI_UP && top >= topi ) || frames > 1000 )
       
   241       break;
       
   242   }
       
   243   
       
   244   timer += timestep;
       
   245   setTimeout('delete(fly_in_cache['+rand_seed+']);', timer);
       
   246   return timer;
       
   247   */
       
   248   timeout += timerstep;
   162   timeout += timerstep;
   249   return timeout;
   163   return timeout;
   250 }
   164 }
   251 
   165 
   252 function abs(i)
   166 function abs(i)