Effects queues

I’m trying to string together a few visual effects and having a ton of
trouble making it work. I’ve searched this forum and read the couple of
threads dealing with this but I’m not having much luck with solutions
presented there. Essentially, I want to fade an image, replace it with a
new image, then appear it back. But in the interests of simplifying the
problem, let’s just say I want to fade an image and then appear it back
(gradually, using the appear effect).

So, I have this in a view:

<%= image_tag("products_main_forever.jpg") %>
<%= image_tag("products_main_wood.jpg") %>
<%= link_to_remote 'Change1', :url => {:action => 'change_image1'} %> <%= link_to_remote 'Change2', :url => {:action => 'change_image2'} %>

and in my controller I have this:

def change_image1
render :update do |page|
page.visual_effect(:fade, “testimage1”, {:queue => “front”})
end
end

def change_image2
render :update do |page|
page.visual_effect(:fade, “testimage2”, {:queue => “front”})
page.visual_effect(:appear, “testimage1”, {:queue => “end”})
end
end

And it works fine - click the first link and the first image fades;
click the second link and the second image fades, then the first image
appears, in order.

However, if I try to fade and appear the same image, with something like
this in the controller:

def change_image2
render :update do |page|
page.visual_effect(:fade, “testimage2”, {:queue => “front”})
page.visual_effect(:appear, “testimage2”, {:queue => “end”})
end
end

It does not work. The image fades, then just comes back in a blink
without the appear effect showing.

I see some stuff out there about :beforeStart and whatnot but can’t seem
to find any syntax for laying that out that works to solve the problem.
I’ve also gone over and over
http://blog.railsdevelopment.com/pages/effect/queue/ and can’t find an
answer there either.

I would appreciate any help or links/pointers to some help.

c.

ive had this problem as well. the fade and the appear are happening on
top
of each other and the element seems to get confused and dissapears at
the
end instead of staying visible. the only solution i’ve found is to
write it
in raw JS; whether by using the << “new Effect(…” method in my
controller/rjs template or simply coding it manually in the view as
inline
JS.

id certainly be interested in hearing a better solution!

ed

On 9/20/06, Cayce B. [email protected] wrote:

So, I have this in a view:
page.visual_effect(:fade, “testimage1”, {:queue => “front”})
And it works fine - click the first link and the first image fades;
end

I would appreciate any help or links/pointers to some help.

c.


Posted via http://www.ruby-forum.com/.


Ed Hickey
Developer
Litmus Media
816-533-0409
[email protected]
A Member of Think Partnership, Inc
www.ThinkPartnership.com
Amex ticker symbol: THK

def change_image2
render :update do |page|
page.visual_effect :fade, “testimage2”, :duration => 0.5
page.delay 0.5 do
page.visual_effect :appear, “testimage2”, :duration => 0.5
end
end
end

That rocks!

Thanks so much for the help.

c.

Peter De Berdt wrote:

def change_image2
render :update do |page|
page.visual_effect :fade, “testimage2”, :duration => 0.5
page.delay 0.5 do
page.visual_effect :appear, “testimage2”, :duration => 0.5
end
end
end