Hey- This calls for a callback.
Callbacks are functions that are triggered before, after, or during an effect. They're part of core effects: http://wiki.script.aculo.us/scriptaculous/show/CoreEffects Give this a shot: new Effect.Opacity('my_elt',{duration:0.3, from:1, to:0, queue:{position:'front',scope:'my_q'}, afterFinish:function(eff){eff.element.innerHTML='Peekaboo!';} }); new Effect.Opacity('my_elt',{duration:0.3, from:0, to:1, queue: {position:'end',scope:'my_q'}}); That should do it for you. BUT... I've got some callback+queue questions of my own for the list. Now, I'd expect that this would do the same thing as the previous example: new Effect.Opacity('my_elt',{duration:0.3, from:1, to:0, queue:{position:'front',scope:'my_q'}, }); new Effect.Opacity('my_elt',{duration:0.3, from:0, to:1, queue:{position:'end',scope:'my_q'}, beforeStart:function(eff){eff.element.innerHTML='Peekaboo!';} }); (I moved the callback to "beforeStart" on the second function.) But it doesn't! beforeStart is run before the *queue*, not before the *effect.* So the innerHTML will change, then it'll fade out, then fade back in. The name "beforeStart" is misleading -- this behavior doesn't quite follow the principle of least surprise, especially considering that afterFinish is run after the effect, not the queue. So, question #1: Is this behavior a feature or a bug? In trying to work around this, I ran across a couple of other callbacks that aren't mentioned on the Core Effects page: beforeSetup and afterSetup. Haven't played around with afterSetup yet, but beforeSetup does what I expected beforeStart to do... it runs the function before the effect (rather than before the queue). So you could use beforeSetup on the second effect (above), instead of afterFinish on the first. Question #2: Did I just miss some documentation about these other callbacks, or is the Core Effects page all there is? If so, I'd be happy to write some more on this stuff. Altay On Aug 6, 11:29 am, briandichiara <[EMAIL PROTECTED]> wrote: > I'm trying to use the Effect Queues but I can't figure out how to > insert a standard function between my 2 effects. I've tried: > > setTimeout("$('caption').innerHTML = caption",300); > new Effect.Opacity('caption', {to:0.0, duration: .3, queue: > {position:'front', scope: 'caption'} }); > new Effect.Opacity('caption', {to:1.0, duration: .3, queue: > {position:'end', scope: 'caption'} }); > > I've also tried: > > new Effect.Opacity('caption', {to:0.0, duration: .3, queue: > {position:'front', scope: 'caption'} }); > new Effect.Opacity('caption', {to:1.0, duration: .3, queue: > {position:'end', scope: 'caption'} }); > var captionQ = Effect.Queues.get('caption'); > var captionC = 1; > captionQ.each(function() { > if(captionC == 2){ > $('caption').innerHTML = caption; > } > captionC++; > }); > > So how exactly do I perform this feat? --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
