Hi, i use prototype and scriptaculous. i change the visibility of the block element p by using the following code: for(var i=0;i<content_divs.length;i++){ content_divs[i].style.display = "none"; } content_divs[id].style.display = "block"; How can i add a fade effect like fading out and in or just fading in to the code above. Regards, dven --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Christophe Porteneuve
2008-Apr-03 13:56 UTC
Re: Adding Fade to display: none and display: block;
dven a écrit :> How can i add a fade effect like fading out and in or just fading in > to the code above.You''ll need to have prototype.js and effects.js loaded. The code below assumes recent versions (say, 1.6.0.2 and 1.8.1, resp.). Just use fade/appear instead of your display settings (which, btw, could have been done using show/hide: content_divs.invoke(''fade''); content_divs[id].appear(); Perhaps you want that to be pretty quick, instead of the 1-second default duration. I''m fond 1/4" myself: content_divs.invoke(''fade'', { duration: 0.25 }); content_divs[id].appear({ duration: 0.25 }); And if there''s just one of your items in content_divs that''s visible, and needs hiding, you should keep a ref to it instead of iterating. But if you won''t keep a ref, you should avoid triggering n-1 useless effects, so: content_divs.each(function(div) { if (div.visible()) div.fade({ duration: 0.25 }); }); content_divs[id].appear({ duration: 0.25 }); ''HTH -- Christophe Porteneuve aka TDD 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 -~----------~----~----~----~------~----~------~--~---