Jump to content

Javascript Slideshow: Fading effect


ProgramPotato

Recommended Posts

Below is code I have for a slideshow:

 <div id="thepic" valign="center"><input type="image" src="ArrowLeft.png" value="<" onclick="move('down')" id="left"/><input type="image" src="ArrowRight.png" value=">" onclick="move('up')" id="right"/></div><input type="image" src="Stop.png" value="stop" onclick="pause()" id="stop" /><script type="text/javascript">var pics=["Placeholder.png", "Placeholder.png", "Placeholder.png", "Placeholder.png"];pics.unshift(pics.pop())function move(dir){if(timer){clearTimeout(timer)}if(dir=="down"){pics.unshift(pics.pop())} if(dir=="up"){pics.push(pics.shift()) }timer=setTimeout(function (){move(dir)}, 5000)document.getElementById("thepic").style.backgroundImage="url("+pics[0]+")";}var timer=setTimeout(function (){move("up")}, 5000) function pause(){clearTimeout(timer);}</script></div>

I was wondering if there is a way to get a fading effect in between pictures, so it looks cleaner. What i really want is an effect like on iOS devices when you slide from picture to picture. I've seen both of these done before and I'd like to have this effect. Thanks!

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...