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
rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-spinoffs?hl=en
-~----------~----~----~----~------~----~------~--~---
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
<briandichi...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
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
rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-spinoffs?hl=en
-~----------~----~----~----~------~----~------~--~---
Thanks a lot! that really helped! As far as your questions, I''ve never even heard of those until now. Thanks again. On Aug 7, 11:58 am, altay <aguve...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> 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 <briandichi...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> 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 rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
Am 07.08.2007 um 18:58 schrieb altay:> > 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 >Please do -- just edit the wiki page! :) Best, Thomas --~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---