views:

1416

answers:

4

I'm developing a website with Ruby on Rails and I have a div with some content. After clicking a link I want that content to get replaced with some other stuff. This works fine with replace_html and rjs.

However, I'd prefer there to be a slight fade/appear (crossfade?) transition between the old and new content. Also the div will be resized a bit so it'd be cooler if this did a grow/shrink effect. I was thinking Scriptaculous must have something like this built in, but I sure can't find it if they do.

By the way there is a great example of this if you have a Basecamp account: login and click "All people" then "Add a new company" to see the effect in action.

Anyone know how to do this? Thanks! Brian

A: 

A strategy could be to put the element in a wrapping div, fade out that wrapping div, replace the HTML in the element, and then fade in the wrapping div again.

I'm not a RJS/scriptaculous user myself, so I'm not sure what the code is, but I'm pretty sure that strategy will work.

August Lilleaas
Hi leethal...thanks for the response. Doing the fade out/fade in sequentially prob won't work. The page will jump (resizing) as the first one disappears and second reappears just after. Also this doesn't do the resizing. I suspect they are doing something more advanced on the basecamp example.
Brian Armstrong
A: 

Fade out the 1st div. Blind in the 2nd div at the same time. As the 1st one fades, the 2nd will appear to expand what's left of the first one.

Well, something like that.

Load up Firebug and step through the code if you want to see what they're calling.

wesgarrison
Is there a way to do it at the same time? I thought it would be sequential. Good idea on the firebug though.
Brian Armstrong
Whoops..I was mistaken. They do happen at the same time! Sorry about that. It still jumps after fade out though.
Brian Armstrong
+3  A: 
Ron DeVera
Brian Armstrong
A: 

One quick way would be to do the replace and then pulsate the div.

Jaryl