473,323 Members | 1,560 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,323 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 9770
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: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.