bravesirrobin-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2007-Jul-05 16:46 UTC
Some effects questions
Hi all. I''m trying to use the SlideDown/SlideUp effects to build nifty dropdown menus. I''ve run into a few stumbling blocks and wanted to run things by the experts. So two questions: - Is there a way to figure out the progress so far in an event? I''d like it so when you mouseout of menu that''s in the process of sliding down from a mouseover, that is stop halfway and start sliding up immediately. This requires that I get the current percentage progress from the SlideDown, stop that event, and start a new SlideUp that starts with that value for progress. I didn''t see any property in the effect for this. - Is there an event that fires at the end of an effect that lets me set a callback? Seems like that would be pretty handy. The website''s article on EffectQueues was pretty handy for all this: http://wiki.script.aculo.us/scriptaculous/show/EffectQueues --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
You would have to patch into the slide functions themselves. There''s a callback on completion, but there''s no callback while the function is running. On Jul 5, 12:46 pm, "bravesirro...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org" <bravesirro...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hi all. I''m trying to use the SlideDown/SlideUp effects to build nifty > dropdown menus. I''ve run into a few stumbling blocks and wanted to run > things by the experts. So two questions: > > - Is there a way to figure out the progress so far in an event? I''d > like it so when you mouseout of menu that''s in the process of sliding > down from a mouseover, that is stop halfway and start sliding up > immediately. This requires that I get the current percentage progress > from the SlideDown, stop that event, and start a new SlideUp that > starts with that value for progress. I didn''t see any property in the > effect for this. > > - Is there an event that fires at the end of an effect that lets me > set a callback? Seems like that would be pretty handy. > > The website''s article on EffectQueues was pretty handy for all this:http://wiki.script.aculo.us/scriptaculous/show/EffectQueues--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Doing a slideup/down effect isn''t really hard to program. You could set your own events and flags inside the functions themselves to do what you want to accomplish. I needed a slide-right, slide-left, so I wrote a little function myself. You may want this as a starting point to build your own. It''s not very elegant but it works. function showAdvanced(p) { Element.show(''advancedPanel'') $(''advancedPanel'').style.left=p+"px" if(p>199) { return; } else { p = p + 20 x=setTimeout("showAdvanced("+p+")",10) } } On Jul 5, 12:46 pm, "bravesirro...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org" <bravesirro...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hi all. I''m trying to use the SlideDown/SlideUp effects to build nifty > dropdown menus. I''ve run into a few stumbling blocks and wanted to run > things by the experts. So two questions: > > - Is there a way to figure out the progress so far in an event? I''d > like it so when you mouseout of menu that''s in the process of sliding > down from a mouseover, that is stop halfway and start sliding up > immediately. This requires that I get the current percentage progress > from the SlideDown, stop that event, and start a new SlideUp that > starts with that value for progress. I didn''t see any property in the > effect for this. > > - Is there an event that fires at the end of an effect that lets me > set a callback? Seems like that would be pretty handy. > > The website''s article on EffectQueues was pretty handy for all this:http://wiki.script.aculo.us/scriptaculous/show/EffectQueues--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Partly correct. beforeUpdate and afterUpdate will both fire while the effect is running [1]. Before/after each update (based roughly on your specified frames/sec and effect duration), naturally. The callbacks available in each effect are: beforeStart Called before the main effects rendering loop is started. beforeUpdate Called on each iteration of the effects rendering loop, before the redraw takes places. afterUpdate Called on each iteration of the effects rendering loop, after the redraw takes places. afterFinish Called after the last redraw of the effect was mad You may have to poke around in the event properties or code (or, perhaps, look at the docs page linked at [1] below), but there are a handful of variables that can help you figure out what you need, notable effect.startOn, effect.finishOn, which contain the start end expected end time of the effect. TAG 1. http://wiki.script.aculo.us/scriptaculous/show/CoreEffects On Jul 5, 2007, at 1:54 PM, Diodeus wrote:> > You would have to patch into the slide functions themselves. There''s a > callback on completion, but there''s no callback while the function is > running. > > On Jul 5, 12:46 pm, "bravesirro...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org" > <bravesirro...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >> Hi all. I''m trying to use the SlideDown/SlideUp effects to build >> nifty >> dropdown menus. I''ve run into a few stumbling blocks and wanted to >> run >> things by the experts. So two questions: >> >> - Is there a way to figure out the progress so far in an event? I''d >> like it so when you mouseout of menu that''s in the process of sliding >> down from a mouseover, that is stop halfway and start sliding up >> immediately. This requires that I get the current percentage progress >> from the SlideDown, stop that event, and start a new SlideUp that >> starts with that value for progress. I didn''t see any property in the >> effect for this. >> >> - Is there an event that fires at the end of an effect that lets me >> set a callback? Seems like that would be pretty handy. >> >> The website''s article on EffectQueues was pretty handy for all >> this:http://wiki.script.aculo.us/scriptaculous/show/EffectQueues > > > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
bravesirrobin-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2007-Jul-05 22:21 UTC
Re: Some effects questions
I was hoping to avoid extending/re-implementing the base effects, as I''d like to build a Cookbook of scriptaculous code which use the core effects. After playing with it some more, I found a way around it. - Keep some JS globals for whether the dropdown is open, changing, or eligible to be closed. - On mouseover, fire the effect, tweak the globals, and plant a timeout for closing the dropdown. - The timeout loops unless the vars are set for closure, at which point is fires the reverse effect. Might have been nice to do with callbacks/partial effects, but this seems pretty robust. Thanks all. bsr On Jul 5, 1:00 pm, Diodeus <diod...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Doing a slideup/down effect isn''t really hard to program. You could > set your own events and flags inside the functions themselves to do > what you want to accomplish. I needed a slide-right, slide-left, so I > wrote a little function myself. You may want this as a starting point > to build your own. It''s not very elegant but it works. > > function showAdvanced(p) { > Element.show(''advancedPanel'') > $(''advancedPanel'').style.left=p+"px" > if(p>199) { > return; > } > else { > p = p + 20 > x=setTimeout("showAdvanced("+p+")",10) > } > > } > > On Jul 5, 12:46 pm, "bravesirro...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org" > > <bravesirro...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > Hi all. I''m trying to use the SlideDown/SlideUp effects to build nifty > > dropdown menus. I''ve run into a few stumbling blocks and wanted to run > > things by the experts. So two questions: > > > - Is there a way to figure out the progress so far in an event? I''d > > like it so when you mouseout of menu that''s in the process of sliding > > down from a mouseover, that is stop halfway and start sliding up > > immediately. This requires that I get the current percentage progress > > from the SlideDown, stop that event, and start a new SlideUp that > > starts with that value for progress. I didn''t see any property in the > > effect for this. > > > - Is there an event that fires at the end of an effect that lets me > > set a callback? Seems like that would be pretty handy. > > > The website''s article on EffectQueues was pretty handy for all this:http://wiki.script.aculo.us/scriptaculous/show/EffectQueues--~--~---------~--~----~------------~-------~--~----~ 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 think if you save the effect reference you could call the cancel method which I believe would halt the effect at whatever point it was in its processing and then start a new slide up effect, you''d have to test that out though. Also I''d avoid globals at all costs in dealing with effects, as im sure your menu has multiple pull downs. Try just using properties of the elements you''re effecting, then they''ll be scoped within the element. On Jul 5, 6:21 pm, "bravesirro...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org" <bravesirro...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> I was hoping to avoid extending/re-implementing the base effects, as > I''d like to build a Cookbook of scriptaculous code which use the core > effects. > > After playing with it some more, I found a way around it. > - Keep some JS globals for whether the dropdown is open, changing, > or eligible to be closed. > - On mouseover, fire the effect, tweak the globals, and plant a > timeout for closing the dropdown. > - The timeout loops unless the vars are set for closure, at which > point is fires the reverse effect. > > Might have been nice to do with callbacks/partial effects, but this > seems pretty robust. Thanks all. > > bsr > > On Jul 5, 1:00 pm, Diodeus <diod...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > Doing a slideup/down effect isn''t really hard to program. You could > > set your own events and flags inside the functions themselves to do > > what you want to accomplish. I needed a slide-right, slide-left, so I > > wrote a little function myself. You may want this as a starting point > > to build your own. It''s not very elegant but it works. > > > function showAdvanced(p) { > > Element.show(''advancedPanel'') > > $(''advancedPanel'').style.left=p+"px" > > if(p>199) { > > return; > > } > > else { > > p = p + 20 > > x=setTimeout("showAdvanced("+p+")",10) > > } > > > } > > > On Jul 5, 12:46 pm, "bravesirro...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org" > > > <bravesirro...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > Hi all. I''m trying to use the SlideDown/SlideUp effects to build nifty > > > dropdown menus. I''ve run into a few stumbling blocks and wanted to run > > > things by the experts. So two questions: > > > > - Is there a way to figure out the progress so far in an event? I''d > > > like it so when you mouseout of menu that''s in the process of sliding > > > down from a mouseover, that is stop halfway and start sliding up > > > immediately. This requires that I get the current percentage progress > > > from the SlideDown, stop that event, and start a new SlideUp that > > > starts with that value for progress. I didn''t see any property in the > > > effect for this. > > > > - Is there an event that fires at the end of an effect that lets me > > > set a callback? Seems like that would be pretty handy. > > > > The website''s article on EffectQueues was pretty handy for all this:http://wiki.script.aculo.us/scriptaculous/show/EffectQueues--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---