473,386 Members | 1,745 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes and contribute your articles to a community of 473,386 developers and data experts.

Image Slide Show

Greetings everyone,

I´ve developed a script to make a slideshow using a holder and the images you need. Just place the images you need within a holder, pass the holder ID to the script and its done!

the parameters are:
holder - id of the holder
speed - change this number to increase/increase speed (lower = faster)
width - width of the holder / images within
height - height of the holder / images within

Expand|Select|Wrap|Line Numbers
  1. //////////////////////////////////////
  2. // Romulo do Nascimento Ferreira     //
  3. //         romulo.nf@gmail.com            //
  4. //////////////////////////////////////
  5.  
  6. function makeSlideShow(holder,speed,width,height) {
  7. gallery = document.getElementById(holder)
  8. gallery.style.width = width + "px"
  9. gallery.style.height = height + "px"
  10. gallery.style.cssFloat = "left"
  11. this.alphaShow = 0
  12. this.alphaFade = 100
  13. this.currentImg = 0
  14. this.animationSpeed = speed
  15. this.images = gallery.getElementsByTagName("img")
  16. this.galleryLength = this.images.length
  17.  
  18.     for (x=0; x<this.galleryLength; x++) {
  19.     this.images[x].style.width = width + "px"
  20.     this.images[x].style.height = height + "px"
  21.     this.images[x].style.position = "absolute"
  22.  
  23.     this.images[x].style.filter = "alpha(opacity=0)"
  24.     this.images[x].style.opacity = "0"
  25.     this.images[x].style.mozOpacity = "0"
  26.     }
  27.  
  28. var _this = this
  29. var startShow = window.setInterval(function(){_this.engine()},this.animationSpeed*10)
  30. }
  31.  
  32. makeSlideShow.prototype.engine = function() {
  33. this.nextImage = this.currentImg + 1 < this.galleryLength ? this.currentImg + 1 : 0
  34.  
  35. this.images[this.currentImg].style.filter = "alpha(opacity=" + this.alphaFade + ")";
  36. this.images[this.currentImg].style.opacity = this.alphaFade < 10? "0.0" + this.alphaFade : this.alphaFade >= 10 && this.alphaFade < 100 ? "0." + this.alphaFade : 1.0;
  37. this.images[this.currentImg].style.mozOpacity = this.alphaFade < 10? "0.0" + this.alphaFade : this.alphaFade >= 10 && this.alphaFade < 100 ? "0." + this.alphaFade : 1.0;
  38.  
  39. this.images[this.nextImage].style.filter = "alpha(opacity=" + this.alphaShow + ")";
  40. this.images[this.nextImage].style.opacity = this.alphaShow < 10? "0.0" + this.alphaShow : this.alphaShow >= 10 && this.alphaShow < 100 ? "0." + this.alphaShow : 1.0;
  41. this.images[this.nextImage].style.mozOpacity = this.alphaShow < 10? "0.0" + this.alphaShow : this.alphaShow >= 10 && this.alphaShow < 100 ? "0." + this.alphaShow : 1.0;
  42.  
  43. this.alphaFade = this.alphaFade - 2
  44. this.alphaShow = this.alphaShow + 2
  45.  
  46.     if (this.alphaFade == 100 || this.alphaShow == 100) {
  47.     this.alphaFade = 100
  48.     this.alphaShow = 0
  49.     this.currentImg = this.currentImg + 1 > this.galleryLength-1 ? 0 : this.currentImg + 1
  50.     }
  51. }
  52.  
To make the script work you will need a holder with images like:
Expand|Select|Wrap|Line Numbers
  1. <div id="galeria1">
  2. <img src="t1.jpg">
  3. <img src="t2.jpg">
  4. <img src="t3.jpg">
  5. </div>
  6.  
And make the call:
Expand|Select|Wrap|Line Numbers
  1. new makeSlideShow('galeria1',4,150,100)
  2.  
Feel free to modify anything, just let my name there :P
Any questions use the email on the code!

Good luck
Jul 4 '07 #1
1 9775
Romulo,
I meant to say that it was a smart way of anchoring images in a slideshow.
thanks.
Jean-Pierre
Aug 27 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Tim | last post by:
Hope someone in the big wide world can help... What I want to do is have an image slideshow which automatically scrolls through a series of images very fast, then pauses when you move your mouse...
2
by: Mekon | last post by:
I have never written a line of script in my life but I need some help with it now. I have this auto generated code which I want to modify if possible The script generates a strip of...
0
by: aarondouglas28 | last post by:
Hey all, I'm hoping someone can help me with a problem I'm having. I have a page that has a javascript based slide show of images on it. The user can press a play button and the page will cycle...
0
by: | last post by:
We have developed a free image-viewer for testing .Net and GDI+ capabilityes. e-View supports a lot of raster and vectorial image formats: -Bitmap (BMP) -Graphics Interchange Format (GIF)...
1
by: www.web20developers.com | last post by:
http://www.web20developers.com http://www.web20developers.com/index.php?option=com_content&task=view... Ajallerix : AJAX, simple, fast Web image gallery demo ; at Novell AJAX -...
1
by: bn4 | last post by:
I have been trying to modify a script that i had working in the past but have lost.. ORIGINAL URL: http://www.thescripts.com/forum/thread147097.html STEPS: I want it to do the following:...
3
by: Nebulism | last post by:
Hi everyone, I am working on a module for my GUI that shows one image with an index value below and would use a scrollbar to control which of the images are displayed. The images are stored in a...
22
idsanjeev
by: idsanjeev | last post by:
Hi i have some image in slide show on load events. i wants to expand image on mouseover from slide show. thanks
2
by: vineetbindal | last post by:
Hi all, We have a slide show in a page which shows slids rotating after every 8-10 seconds with some descriptions about them. The problem is if the connection speed is slow then the page loads...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.