Hi Christophe,
2006/10/4, Christophe Porteneuve aka TDD <[EMAIL PROTECTED]>:
> 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 [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/rubyonrails-spinoffs
-~----------~----~----~----~------~----~------~--~---