Forum Moderators: open

Message Too Old, No Replies

how to achieve image swap with fade in?

         

ws21

5:51 pm on Jun 23, 2009 (gmt 0)

10+ Year Member



Hi Guys!
I'm trying to create an image swap where the image fades in rather than just appears.
<snip>
I assume it relies on the javascript from a basic image swap tweaked to show the fade in.
Can anyone point me to a script or tutorial for this?

Thanks in advance!

[edited by: engine at 9:41 am (utc) on June 24, 2009]
[edit reason] No urls, please see WebmasterWorld TOS [/edit]

whoisgregg

6:27 pm on Jun 25, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Welcome to WebmasterWorld, ws21!

To achieve this, instead of simply swapping the src value of the image, use absolute positioning and z-index to place the new image below the old image. Then, using setTimeout have a function reduce the opacity of the top image by a few percent every 1/10th of a second or so.