[Rails-spinoffs] Executing custom effect for n seconds

Thomas Fuchs
Fri, 24 Jun 2005 01:41:36 -0000

Use transitions for this.

Tranistions take 0..1 in and mangle that value, and put 0..1 out again.

so:

Effect2.Transitions.reverse  = function(pos) {
   return 1-pos;
}

Reverses the effect.

Use with an anonymous funtion as an option:

     transition:function(pos){return 1-pos;}

Or, better yet:

     Effect2.Transitions.pulse = function(pos) {
       return (-Math.cos(10*pos*Math.PI)/2);
     }

This allows all core effects to use it. The above should pulse 10
times. (I haven''t tested it).

Note that there''s no easy way to give parameters to Transitions (yet).

Thomas


Am 24.06.2005 um 06:59 schrieb Justin Palmer:

> Glad to see this list get going!
>
> I have a custom effect ''Pulse'' that basically does an
opacity fade
> in/out.
> I want to execute this effect with a custom duration.
>
> I''m looking for a consistent approach that is inline with
> script.alicio.us and Prototype.
>
> Is there a way to do something like this (pseudo code):
>  Effect2.Pulse = function(element) {
>     new FadeIn(element, {afterFinish: new Fadeout})
> }
>
> Effect.Pulsate = function(element) {
>    render(Effect2.Pulse, {duration: 10});
> }
>
> I have most of this working, but the Pulse effect only runs 1, and
> when supplied with duration: n, it will take n seconds to render
> the Pulse effect once.
> What I would like to do is ''repeat'' this effect for a
specific
> duration.
>
> Cheers,
>   -Justin Palmer
>
> ----------------------------------------------
> Encytemedia.com
> Professional User Interface Design for Rails Applications
>
> _______________________________________________
> Rails-spinoffs mailing list
> Rails-spinoffs@lists.rubyonrails.org
> http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
>