# Rjs fade one image into another

**URL:** <https://www.ruby-forum.com/t/rjs-fade-one-image-into-another/105945>\
**Category:** Rails\
**Created:** [June 4, 2007, 9:22pm UTC](https://www.ruby-forum.com/t/rjs-fade-one-image-into-another/105945 "2007-06-04T21:22:17Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![mark](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/e9c0ed/32.png) [@mark](https://www.ruby-forum.com/u/mark)\
**Post date:** [June 4, 2007, 9:22pm UTC](https://www.ruby-forum.com/t/rjs-fade-one-image-into-another/105945/1 "2007-06-04T21:22:17Z")

</div>

Hi,

Has anyone got any suggestions on the best effect to use when fadding  
one image into another?

Thanks  
Mark

---

<div class="post-metadata">

**Author:** ![mark](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/e9c0ed/32.png) [@mark](https://www.ruby-forum.com/u/mark)\
**Post date:** [June 4, 2007, 9:44pm UTC](https://www.ruby-forum.com/t/rjs-fade-one-image-into-another/105945/2 "2007-06-04T21:44:15Z")

</div>

I’ve wanted to do this, but haven’t really found anything. You can try  
playing with queues to make both effects (fade in and fade out) happen  
simultaneously, but the main difficulty is that it’s HTML, and the  
normal  
flow layout will not place items on top of each other.

The only way I can think of doing it is with some CSS absolute  
positioning,  
which is always fun to get working across browsers correctly.

Jason

---

<div class="post-metadata">

**Author:** ![mark](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/e9c0ed/32.png) [@mark](https://www.ruby-forum.com/u/mark)\
**Post date:** [June 4, 2007, 9:58pm UTC](https://www.ruby-forum.com/t/rjs-fade-one-image-into-another/105945/3 "2007-06-04T21:58:15Z")

</div>

abs positioning, science no.

if your image is like this

then you do

assuming they are the same size img1 should now be over img2.  
now all you need is to activate the fade effect on img 1.

---

<div class="post-metadata">

**Author:** ![mark](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/e9c0ed/32.png) [@mark](https://www.ruby-forum.com/u/mark)\
**Post date:** [June 4, 2007, 9:58pm UTC](https://www.ruby-forum.com/t/rjs-fade-one-image-into-another/105945/4 "2007-06-04T21:58:32Z")

</div>

I am a huge fan of this little library:  
Cross Fade Anything  
[http://www.millstream.com.au/view/code/cross-fade-anything](http://www.millstream.com.au/view/code/cross-fade-anything)

On 6/4/07, Jason R. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> > –  
> > Posted via [http://www.ruby-forum.com/](http://www.ruby-forum.com/) .
> 
> >

–  
Thanks,  
-Steve  
[http://www.stevelongdo.com](http://www.stevelongdo.com)

---

<div class="post-metadata">

**Author:** ![mark](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/e9c0ed/32.png) [@mark](https://www.ruby-forum.com/u/mark)\
**Post date:** [June 4, 2007, 10:05pm UTC](https://www.ruby-forum.com/t/rjs-fade-one-image-into-another/105945/5 "2007-06-04T22:05:32Z")

</div>

Eh, whoops. That Crossfader library is cool! I will definitely be using  
that.

As for the image hack, I guess I was thinking of fading divs through  
each  
other, not just images. Good to know about images and floating.

Jason

---

<div class="post-metadata">

**Author:** ![mark](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/e9c0ed/32.png) [@mark](https://www.ruby-forum.com/u/mark)\
**Post date:** [June 4, 2007, 10:17pm UTC](https://www.ruby-forum.com/t/rjs-fade-one-image-into-another/105945/6 "2007-06-04T22:17:24Z")

</div>

thanks for the link, looks good 🙂

Is it possible just to greyscale am image?

---

<div class="post-metadata">

**Author:** ![mark](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/e9c0ed/32.png) [@mark](https://www.ruby-forum.com/u/mark)\
**Post date:** [June 5, 2007, 10:44am UTC](https://www.ruby-forum.com/t/rjs-fade-one-image-into-another/105945/7 "2007-06-05T10:44:50Z")

</div>

Mark wrote:

> Hi,
> 
> Has anyone got any suggestions on the best effect to use when fadding  
> one image into another?
> 
> Thanks  
> Mark

I’m working on something along these lines right now with YUI. I’m still  
having a few issues with the image preloading, but other than that it’s  
working ok. I’ll post when completed.
