Hi *, I have a little problem with Effect.toggle. I use Effect.toogle(''id_of_the_element'',''appear'') to display an Element on my page and this works like expected, but I want to my element to have an opacity of 0.8, when it appeared. I tried Effect.toogle(''id_of_the_element'',''appear'',{to:0.8}), but then the fade doesn''t work, because it now only fades to an opacity of 0.8. This behaviour is not to surprising, but not what I want. Is there any good workaround or must I build my one toggle function? Tim --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Hello Tim, Tim Bellinghausen a écrit :> I have a little problem with Effect.toggle. I use > Effect.toogle(''id_of_the_element'',''appear'') to display an Element on > my page and this works like expected, but I want to my element to have > an opacity of 0.8, when it appeared. I triedCould you be more precise? e.g.: - do you use toggle repeatedly to display/hide, or just once, in which case using the original effect would work better? - do you want the *minimum* (hidden-position) opacity to be 0.8, or the *maximum* (visible-position) opacity to be 0.8? - In short, can you provide a call sequence and describe the desired opacity of your element before the 1st call, between calls and after the last call? -- 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 -~----------~----~----~----~------~----~------~--~---
Hi, 2006/10/4, Christophe Porteneuve aka TDD <tdd-x+CfDp/qHev2eFz/2MeuCQ@public.gmane.org>:> > Hello Tim, > > Could you be more precise? e.g.:I''ll try :-)> - do you use toggle repeatedly to display/hide, or just once, in which > case using the original effect would work better?It should be possible to use it repeatedly, I use it to blend in/off a layer with some options.> - do you want the *minimum* (hidden-position) opacity to be 0.8, or the > *maximum* (visible-position) opacity to be 0.8?The minimum position should be 0, the maximum 0.8.> - In short, can you provide a call sequence and describe the desired > opacity of your element before the 1st call, between calls and after the > last call?Before first call: opacity: 0, On first call: let the element appear, final opacity: 0.8 One second call: fade the element, final opacity: 0 and so on. To reach, that the appear part of the toggle finshes with an opacity of 0.8 I treid to set to:0.8, but this causes the fade to stop working, because it also gets the to property set to 0.8, and thats the problem. I think I need to do my own toggle, but I would be happy for any idea. Greets, Tim --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Hey Tim, Tim Bellinghausen a écrit :> It should be possible to use it repeatedly, I use it to blend in/off > a layer with some options. > > Before first call: opacity: 0, > On first call: let the element appear, final opacity: 0.8 > One second call: fade the element, final opacity: 0 > and so on.Alright.> To reach, that the appear part of the toggle finshes with an opacity > of 0.8 I treid to set to:0.8, but this causes the fade to stop > working, because it also gets the to property set to 0.8, and thats > the problem. I think I need to do my own toggle, but I would be happy > for any idea.Yeah, that''s nominal behavior. That''s because your options hash is passed untouched (or almost so) to the effects, therefore the fade has a to:0.8 to... By default, Appear and Fade use 0-X and X-0 as from/to, where X is the element''s current opacity. So you''d have to create your own toggler. Probably something like this (ugh, massive redundancy over existing code, *sob*): Effect.boundToggleAppear = function(element, maxOpacity) { if (undefined === maxOpacity) maxOpacity = 1.0; element = $(element); var inOptions = Object.extend({ queue: { position:''end'', scope:(element.id || ''global''), limit: 1 }, from: 0, to: maxOpacity }, arguments[2] || {}); var outOptions = Object.extend(inOptions, { from: maxOpacity, to: 0 }); var options = element.visible() ? outOptions : inOptions; Effect[element.visible() ? ''Fade'' : ''Appear''](element, options); }; Didn''t test. ''Should work, though. -- 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 -~----------~----~----~----~------~----~------~--~---
Hi Christophe, 2006/10/4, Christophe Porteneuve aka TDD <tdd-x+CfDp/qHev2eFz/2MeuCQ@public.gmane.org>:> Yeah, that''s nominal behavior. That''s because your options hash is > passed untouched (or almost so) to the effects, therefore the fade has a > to:0.8 to...I know, that''s why I asked :-)>> So you''d have to create your own toggler. Probably something like this > (ugh, massive redundancy over existing code, *sob*):And that is, what I hoped to avoid :-)> Effect.boundToggleAppear = function(element, maxOpacity) { > if (undefined === maxOpacity) > maxOpacity = 1.0; > element = $(element); > var inOptions = Object.extend({ > queue: { position:''end'', scope:(element.id || ''global''), limit: 1 }, > from: 0, to: maxOpacity > }, arguments[2] || {}); > var outOptions = Object.extend(inOptions, { > from: maxOpacity, to: 0 }); > var options = element.visible() ? outOptions : inOptions; > Effect[element.visible() ? ''Fade'' : ''Appear''](element, options); > }; > > Didn''t test. ''Should work, though.Thanks for this, it did not wor, but I won''t complain about it, the problem was, that after the second Object.extend inOptions and outOptions had the same values for from and to, so I modified your solution a bit, now it doesen''t look so good, but it works and that is enough for me :-) Effect.boundToggleAppear = function(element, maxOpacity) { if (undefined === maxOpacity) maxOpacity = 1.0; element = $(element); var visible = element.visible(); var from = 0; var to = maxOpacity; var effect = ''Appear''; if (visible) { from = maxOpacity; to = 0; effect = ''Fade''; } var options = Object.extend({ queue : { position:''end'', scope:(element.id || ''global''), limit: 1 }, from : from, to : to, }, arguments[2] || {}); Effect[effect](element, options); }; Maybe this will be useful for someone else too. Greets, Tim --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Hey there, Tim Bellinghausen a écrit :> outOptions had the same values for from and to, so I modified your > solution a bit, now it doesen''t look so good, but it works and that is > enough for me :-)Sorry about that. You just have to change the line to this: var outOptions = Object.extend(Object.clone(inOptions), {from: maxOpacity, to: 0 }); -- 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 -~----------~----~----~----~------~----~------~--~---
Hi Christophe, I think there is nothing to apologize for, I am again and again amazed how fast and how detailed nearly every question gets answered, also those questions, which in nearly every other mailinglist, forum or newsgroup would get an "Use Google" or "RTFM" as an answer. By the way, since I found a working solution for this bug on my own, I think I will use this, because I think it uses less resources, although your solution is the more beautiful one :-) Greets, Tim --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---