Hello, like many others I''m attempting to create a custom effect by chaining multiple other effects together, one after another. I''m having some trouble getting the behavior I expect from the EffectQueues page in the wiki: http://wiki.script.aculo.us/scriptaculous/show/EffectQueues I have two effects here, a Grow and a Pulsate: Effect.MyEffect = function(element) { element = $(element); Effect.Grow(element, { direction: ''top-left'', duration: 5.0, queue: ''end'' }); Effect.Pulsate(element, { queue: ''end'' }); } With this code I only see the Grow and not the Pulsate. It doesn''t make a difference if I switch the order of the two Effect declarations. If I add an alert as an ''afterFinish'' event for the Pulsate effect, I see it as the page finishes loading, before the Grow happens, again independent of the order of the declarations. If I change "queue: ''end''" to, "queue: {position: ''end''}", which the wiki says is equivalent, I get this error: "Effect.Queues.get(typeof this.options.queue == "string" ? "global" : this.options.queue.scope) has no properties" which seems to indicate that the ''scope'' variable has to be there if you define the ''queue'' option as a hash. If I do specify the scope either as ''global'' or as another value, I get the same behavior as in the first case. Am I missing something about the use of the queue? I tried the alternative method of including the second effect as the first effect''s "afterFinish" callback, and that works as it should. If I''m not mistaken, this method, despite its drawbacks, is still in use in the Scriptaculous source code, for example in Effect.Shake, consisting of several Effect.Move''s chained together in this manner. Perhaps there''s a reason for that. Lastly, can someone set me straight on "Effect.Grow" vs. "new Effect.Grow"? I''ve seen conflicting information, some of which is probably out of date. And does this have anything to do with some effects being defined like this: Effect.Shake = function(element) { ... and some like this: Effect.Morph = Class.create(); Object.extend(Object.extend(Effect.Morph.prototype, Effect.Base.prototype), { ... Thanks for any help you can offer. I''m using Scriptaculous 1.7.0 and Prototype 1.5.0. -Jay --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Have you tried it with a scoped queue? {queue: {position:''end'', scope: ''someName''}} I haven''t had problems chaining effects this way in the past (I almost always use a scope). Perhaps if you have a link to a full page I could tinker with your source until it worked. TAG On Apr 17, 2007, at 7:36 PM, Jay K wrote:> > Hello, > like many others I''m attempting to create a custom effect by chaining > multiple other effects together, one after another. I''m having some > trouble getting the behavior I expect from the EffectQueues page in > the wiki: > http://wiki.script.aculo.us/scriptaculous/show/EffectQueues > > I have two effects here, a Grow and a Pulsate: > > Effect.MyEffect = function(element) { > element = $(element); > Effect.Grow(element, > { direction: ''top-left'', > duration: 5.0, > queue: ''end'' > }); > > Effect.Pulsate(element, > { > queue: ''end'' > }); > } > > With this code I only see the Grow and not the Pulsate. It doesn''t > make a difference if I switch the order of the two Effect > declarations. If I add an alert as an ''afterFinish'' event for the > Pulsate effect, I see it as the page finishes loading, before the Grow > happens, again independent of the order of the declarations. > > If I change "queue: ''end''" to, "queue: {position: ''end''}", which the > wiki says is equivalent, I get this error: > "Effect.Queues.get(typeof this.options.queue == "string" ? "global" : > this.options.queue.scope) has no properties" > which seems to indicate that the ''scope'' variable has to be there if > you define the ''queue'' option as a hash. > > If I do specify the scope either as ''global'' or as another value, I > get the same behavior as in the first case. Am I missing something > about the use of the queue? > > I tried the alternative method of including the second effect as the > first effect''s "afterFinish" callback, and that works as it should. > If I''m not mistaken, this method, despite its drawbacks, is still in > use in the Scriptaculous source code, for example in Effect.Shake, > consisting of several Effect.Move''s chained together in this manner. > Perhaps there''s a reason for that. > > Lastly, can someone set me straight on "Effect.Grow" vs. "new > Effect.Grow"? I''ve seen conflicting information, some of which is > probably out of date. And does this have anything to do with some > effects being defined like this: > Effect.Shake = function(element) { ... > and some like this: > Effect.Morph = Class.create(); > Object.extend(Object.extend(Effect.Morph.prototype, > Effect.Base.prototype), { ... > > Thanks for any help you can offer. I''m using Scriptaculous 1.7.0 and > Prototype 1.5.0. > -Jay > > > >--~--~---------~--~----~------------~-------~--~----~ 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 Jay, Use the "new" operator for creating your effects, otherwise they won''t be able to run properly when combined. As for the queues, you *should* use a custom queue indeed, instead of the global queue. But then, you need not only the position, but also the scope (the name of the queue). Here''s a per-element queue that should work: Effect.myEffect = function(elt) { new Effect.Grow(elt, { direction: ''top-left'', duration: 5, queue: { scope: elt.id, position: ''end'' }); new Effect.Pulsate(elt, {queue: { scope: elt.id, position: ''end'' }); } -- Christophe Porteneuve a.k.a. TDD "[They] did not know it was impossible, so they did it." --Mark Twain Email: tdd-x+CfDp/qHev2eFz/2MeuCQ@public.gmane.org --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Tom and Christophe, thanks very much for your help. I''ve set up a test page here: http://www.autonoetic.com/dev/test/effectQueueTest.html All my custom javascript is inside that page''s source. I''m using the element id as the scope for the queue, as suggested, and calling all effects with ''new''. The effect still seems to be the same; though it''s tough to say exactly what''s happening, I only see the Grow effect. Let me know what you think, and thanks again. -Jay On Apr 18, 2:30 am, Christophe Porteneuve <t...-x+CfDp/qHev2eFz/2MeuCQ@public.gmane.org> wrote:> Hey Jay, > > Use the "new" operator for creating your effects, otherwise they won''t > be able to run properly when combined. As for the queues, you *should* > use a custom queue indeed, instead of the global queue. But then, you > need not only the position, but also the scope (the name of the queue). > > Here''s a per-element queue that should work: > > Effect.myEffect = function(elt) { > new Effect.Grow(elt, { direction: ''top-left'', duration: 5, > queue: { scope: elt.id, position: ''end'' }); > new Effect.Pulsate(elt, {queue: { scope: elt.id, position: ''end'' }); > > } > > -- > Christophe Porteneuve a.k.a. TDD > "[They] did not know it was impossible, so they did it." --Mark Twain > Email: t...-x+CfDp/qHev2eFz/2MeuCQ@public.gmane.org--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
I can duplicate. It works for me in Firefox if I change "position:''end''" to "position:''front''" in the Grow queue. There are some weird things going on. Oddly, (also in Firefox/OS X) if I remove the position attribute from both queues, I can switch the order of the effects, and get the same result. (no, it''s not cached) Perhaps it''s running them in parallel (two or three pulsates, not five), although it''s not visually noticeable for me. The same occurs if I remove the position attribute entirely from the Grow queue declaration. TAG On Apr 18, 2007, at 10:08 AM, Jay K wrote:> > Tom and Christophe, thanks very much for your help. I''ve set up a > test page here: > > http://www.autonoetic.com/dev/test/effectQueueTest.html > > All my custom javascript is inside that page''s source. I''m using the > element id as the scope for the queue, as suggested, and calling all > effects with ''new''. The effect still seems to be the same; though > it''s tough to say exactly what''s happening, I only see the Grow > effect. Let me know what you think, and thanks again. > -Jay > > On Apr 18, 2:30 am, Christophe Porteneuve <t...-x+CfDp/qHev2eFz/2MeuCQ@public.gmane.org> wrote: >> Hey Jay, >> >> Use the "new" operator for creating your effects, otherwise they >> won''t >> be able to run properly when combined. As for the queues, you >> *should* >> use a custom queue indeed, instead of the global queue. But then, >> you >> need not only the position, but also the scope (the name of the >> queue). >> >> Here''s a per-element queue that should work: >> >> Effect.myEffect = function(elt) { >> new Effect.Grow(elt, { direction: ''top-left'', duration: 5, >> queue: { scope: elt.id, position: ''end'' }); >> new Effect.Pulsate(elt, {queue: { scope: elt.id, position: >> ''end'' }); >> >> } >> >> -- >> Christophe Porteneuve a.k.a. TDD >> "[They] did not know it was impossible, so they did it." --Mark Twain >> Email: t...-x+CfDp/qHev2eFz/2MeuCQ@public.gmane.org > > > >--~--~---------~--~----~------------~-------~--~----~ 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 Jay, Don''t have time just now, but know that your issue is specific to the Grow/Shrink pair, which rely on complex internal Effect.Move-based, parallel-synchronized execution stuff. Just try with another effect, say, Effect.BlindDown. It will work. I''ll try to find time and investigate how Grow/Shrink don''t seme to bend themselves to queues, as this is clearly a bug: they should be queueable. -- Christophe Porteneuve a.k.a. TDD "[They] did not know it was impossible, so they did it." --Mark Twain Email: tdd-x+CfDp/qHev2eFz/2MeuCQ@public.gmane.org --~--~---------~--~----~------------~-------~--~----~ 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, Christophe and Tom, for taking the time to look into this. I got the same results as Tom when I tried his ideas. For now I''ll probably just find some way to hack around it, but if I come up with any kind of real solution to the problem with queueing Grow/Shrink I will certainly let you know. -Jay On Apr 18, 3:51 pm, Christophe Porteneuve <t...-x+CfDp/qHev2eFz/2MeuCQ@public.gmane.org> wrote:> Hey Jay, > > Don''t have time just now, but know that your issue is specific to the > Grow/Shrink pair, which rely on complex internal Effect.Move-based, > parallel-synchronized execution stuff. > > Just try with another effect, say, Effect.BlindDown. It will work. > I''ll try to find time and investigate how Grow/Shrink don''t seme to bend > themselves to queues, as this is clearly a bug: they should be queueable. > > -- > Christophe Porteneuve a.k.a. TDD > "[They] did not know it was impossible, so they did it." --Mark Twain > Email: t...-x+CfDp/qHev2eFz/2MeuCQ@public.gmane.org--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---