PDA

View Full Version : General question about slideshows.



Cybershell
01-07-2005, 11:27 PM
http://www.dynamicdrive.com/dynamicindex14/fadeinslideshow.htm
http://www.dynamicdrive.com/dynamicindex14/translucentslide.htm
http://www.dynamicdrive.com/dynamicindex14/pixelate.htm
http://www.dynamicdrive.com/dynamicindex14/dropitslide.htm
http://www.dynamicdrive.com/dynamicindex14/carousel.htm
http://www.dynamicdrive.com/dynamicindex14/bookflip.htm

I think that all mentioned above slideshows are brilliant. For my web page I need slideshow that will appear from nowhere and will disappear in nowhere. That is why I would like to stop slideshow on the very last slide. How can I modify any of mentioned scripts to stop endless rotation? Thank you in advance for your help.

Minos
01-08-2005, 07:29 AM
I've only looked at one so far, but your third link (pixelate) change the following code:



function slideit(){
if (!document.images) return
if (ie55) document.images.slide.filters[0].apply()
document.images.slide.src=imageholder[whichimage].src
if (ie55) document.images.slide.filters[0].play()
whichlink=whichimage
whichimage=(whichimage<slideimages.length-1)? whichimage+1 : 0
setTimeout("slideit()",slidespeed+pixeldelay)
}


to:



function slideit(){
if (!document.images) return
if (ie55) document.images.slide.filters[0].apply()
document.images.slide.src=imageholder[whichimage].src
if (ie55) document.images.slide.filters[0].play()
whichlink=whichimage
if (whichimage<slideimages.length-1){
whichimage+=1
setTimeout("slideit()",slidespeed+pixeldelay)
}
}

Minos
01-09-2005, 08:52 AM
Okay, fourth one down, dropitslide, works the same way

Change:


function movepic(){
if (curpos<0){
curpos=Math.min(curpos+degree,0)
tempobj.style.top=curpos+"px"
}
else{
clearInterval(dropslide)
nextcanvas=(curcanvas=="canvas0")? "canvas0" : "canvas1"
tempobj=ie4? eval("document.all."+nextcanvas) : document.getElementById(nextcanvas)
tempobj.innerHTML='<img src="'+dropimages[nextimageindex]+'">'
nextimageindex=(nextimageindex<dropimages.length-1)? nextimageindex+1 : 0
setTimeout("rotateimage()",pause)
}
}


to:



function movepic(){
if (curpos<0){
curpos=Math.min(curpos+degree,0)
tempobj.style.top=curpos+"px"
}
else{
clearInterval(dropslide)
nextcanvas=(curcanvas=="canvas0")? "canvas0" : "canvas1"
tempobj=ie4? eval("document.all."+nextcanvas) : document.getElementById(nextcanvas)
tempobj.innerHTML='<img src="'+dropimages[nextimageindex]+'">'
if (nextimageindex<dropimages.length-1){
nextimageindex+=1
setTimeout("rotateimage()",pause)
}
}
}

Minos
01-09-2005, 08:54 AM
You know what, instead of posting the changes for them, all but the last 2 can be modified the same way. When looking at the original code, you should immediately look for the function 'setTimeout'. Try doing a Find in notepad. This line, and the line above it should look similar to:



whichimage=(whichimage<slideimages.length-1)? whichimage+1 : 0
setTimeout("slideit()",slidespeed+pixeldelay)


with only the variable names differing.

This basically reads as "If whichimage is less than slideimages.length-1, then whichimage = whichimage + 1. If not, whichimage = 0. Now call function slideit() in this number of milliseconds."

Sooooo, if the image it is on is LESS than the number of images, increment it. If it isn't, set it back to zero (so now we're back at the first image). Then, no matter the outcome, call slideit and change the picture. To modify it, you would change the above code to:



if (whichimage<slideimages.length-1){
whichimage+=1
setTimeout("slideit()",slidespeed+pixeldelay)
}


This now reads "If whichimage is less than slideimages.length-1, then whichimage = whichimage+1, and call slideit() in this number of milliseconds."

Sooooo, if the image it is on is LESS than the number of images, increment and call the function again (change the image again). If it isn't, oh well, we're done. The slideit function is no longer called, images are no longer changing.

Make any sense?