Pomoc - Szukaj - Użytkownicy - Kalendarz
Pełna wersja: Skrypt podmieniający zdjęcia
Forum PHP.pl > Forum > Po stronie przeglądarki > JavaScript
kajko84
Witam

Mam taki oto skrypt:

  1. var obrazki = new Array ("./images/startowe/1.jpg", "./images/startowe/2.jpg", "./images/startowe/3.jpg", "./images/startowe/4.jpg", "./images/startowe/5.jpg", "./images/startowe/6.jpg", "./images/startowe/7.jpg", "./images/startowe/8.jpg", "./images/startowe/9.jpg", "./images/startowe/10.jpg", "./images/startowe/11.jpg", "./images/startowe/12.jpg")
  2. var licz=0
  3. var stop=0
  4. function animuj() {
  5. if (document.images) {
  6. if ( (document.banerrekl.complete) && (stop<12) ) {
  7. licz++
  8. stop++
  9. if (licz==12) {
  10. licz=0
  11. }
  12. document.banerrekl.src=obrazki[licz]
  13. }
  14. setTimeout ("animuj()", 3*2000)
  15. }
  16. }


skrypt wyswietla kolejno 12 fotkek i po zakonczeniu zatrzymuje sie na pierwszej.
chcialbym go rozbudowac o efekt przejsc miedzy zdjeciami, jakis fade out - fade in
JS znam dojsc slabo w zwiazku z tym czy ktos z was robil cos podobnego? albo zna jakis gotowy skrypt kotry moglbym do tego wykorzystac? przyznam ze szukalem i nie znalazlem nic co by spelnialo moje oczekiwania. prosze o pomoc smile.gif

pozdrawiam serdecznie
revyag
Zainteresuj się stylem css opacity, jeśli połączysz to ze słowami kluczowymi fade,javascript to google dużo Ci powie smile.gif
kajko84
dzieki revyag, skorzystalem z porady i uzyskalem to co chcialem smile.gif poprostu trzeba wiedziec czego szukac winksmiley.jpg

znalazlem bardzo fajny skrypt na DynamicDrive
dzieki i pozdrawiam

----- EDIT -----

a moze ktos z was pomoglby zmodyfikowac mi ponizszy skrypt tak zeby nie ladowal wszystkich zdjec naraz tylko kolejno?

  1. var fadeimages=new Array()
  2. fadeimages[0]=["./images/startowe/1.jpg", "", ""]
  3. fadeimages[1]=["./images/startowe/2.jpg", "", ""]
  4. fadeimages[2]=["./images/startowe/3.jpg", "", ""]
  5. fadeimages[3]=["./images/startowe/4.jpg", "", ""]
  6. fadeimages[4]=["./images/startowe/5.jpg", "", ""]
  7. fadeimages[5]=["./images/startowe/6.jpg", "", ""]
  8. fadeimages[6]=["./images/startowe/7.jpg", "", ""]
  9. fadeimages[7]=["./images/startowe/8.jpg", "", ""]
  10. fadeimages[8]=["./images/startowe/9.jpg", "", ""]
  11. fadeimages[9]=["./images/startowe/10.jpg", "", ""]
  12. fadeimages[10]=["./images/startowe/11.jpg", "", ""]
  13. fadeimages[11]=["./images/startowe/12.jpg", "", ""]
  14.  
  15. var fadebgcolor="white"
  16.  
  17. ////NO need to edit beyond here/////////////
  18.  
  19. var fadearray=new Array() //array to cache fadeshow instances
  20. var fadeclear=new Array() //array to cache corresponding clearinterval pointers
  21.  
  22. var dom=(document.getElementById) //modern dom browsers
  23. var iebrowser=document.all
  24.  
  25. function fadeshow(theimages, fadewidth, fadeheight, borderwidth, delay, pause, displayorder){
  26. this.pausecheck=pause
  27. this.mouseovercheck=0
  28. this.delay=delay
  29. this.degree=10 //initial opacity degree (10%)
  30. this.curimageindex=0
  31. this.nextimageindex=1
  32. fadearray[fadearray.length]=this
  33. this.slideshowid=fadearray.length-1
  34. this.canvasbase="canvas"+this.slideshowid
  35. this.curcanvas=this.canvasbase+"_0"
  36. if (typeof displayorder!="undefined")
  37. theimages.sort(function() {return 0.5 - Math.random();}) //thanks to Mike (aka Mwinter) :)
  38. this.theimages=theimages
  39. this.imageborder=parseInt(borderwidth)
  40. this.postimages=new Array() //preload images
  41. for (p=0;p<theimages.length;p++){
  42. this.postimages[p]=new Image()
  43. this.postimages[p].src=theimages[p][0]
  44. }
  45.  
  46. var fadewidth=fadewidth+this.imageborder*2
  47. var fadeheight=fadeheight+this.imageborder*2
  48.  
  49. if (iebrowser&&dom||dom) //if IE5+ or modern browsers (ie: Firefox)
  50. document.write('<div id="master'+this.slideshowid+'" style="position:relative;width:'+fadewidth+'px;height:'+fadeheight+'px;overflow:hidden;"><div id="'+this.canvasbase+'_0" style="position:absolute;width:'+fadewidth+'px;height:'+fadeheight+'px;top:0;left:0;filter:progid:DXImageTransform.Microsoft.alpha(opacity=10);-moz-opacity:10;-khtml-opacity:10;background-color:'+fadebgcolor+'"></div><div id="'+this.canvasbase+'_1" style="position:absolute;width:'+fadewidth+'px;height:'+fadeheight+'px;top:0;left:0;filter:progid:DXImageTransform.Microsoft.alpha(opacity=10);-moz-opacity:10;background-color:'+fadebgcolor+'"></div></div>')
  51. else
  52. document.write('<div><img name="defaultslide'+this.slideshowid+'" src="'+this.postimages[0].src+'"></div>')
  53.  
  54. if (iebrowser&&dom||dom) //if IE5+ or modern browsers such as Firefox
  55. this.startit()
  56. else{
  57. this.curimageindex++
  58. setInterval("fadearray["+this.slideshowid+"].rotateimage()", this.delay)
  59. }
  60. }
  61.  
  62. function fadepic(obj){
  63. if (obj.degree<100){
  64. obj.degree+=10
  65. if (obj.tempobj.filters&&obj.tempobj.filters[0]){
  66. if (typeof obj.tempobj.filters[0].opacity=="number") //if IE6+
  67. obj.tempobj.filters[0].opacity=obj.degree
  68. else //else if IE5.5-
  69. obj.tempobj.style.filter="alpha(opacity="+obj.degree+")"
  70. }
  71. else if (obj.tempobj.style.MozOpacity)
  72. obj.tempobj.style.MozOpacity=obj.degree/101
  73. else if (obj.tempobj.style.KhtmlOpacity)
  74. obj.tempobj.style.KhtmlOpacity=obj.degree/100
  75. }
  76. else{
  77. clearInterval(fadeclear[obj.slideshowid])
  78. obj.nextcanvas=(obj.curcanvas==obj.canvasbase+"_0")? obj.canvasbase+"_0" : obj.canvasbase+"_1"
  79. obj.tempobj=iebrowser? iebrowser[obj.nextcanvas] : document.getElementById(obj.nextcanvas)
  80. obj.populateslide(obj.tempobj, obj.nextimageindex)
  81. obj.nextimageindex=(obj.nextimageindex<obj.postimages.length-1)? obj.nextimageindex+1 : 0
  82. setTimeout("fadearray["+obj.slideshowid+"].rotateimage()", obj.delay)
  83. }
  84. }
  85.  
  86. fadeshow.prototype.populateslide=function(picobj, picindex){
  87. var slideHTML=""
  88. if (this.theimages[picindex][1]!="") //if associated link exists for image
  89. slideHTML='<a href="'+this.theimages[picindex][1]+'" target="'+this.theimages[picindex][2]+'">'
  90. slideHTML+='<img src="'+this.postimages[picindex].src+'" border="'+this.imageborder+'px">'
  91. if (this.theimages[picindex][1]!="") //if associated link exists for image
  92. slideHTML+='</a>'
  93. picobj.innerHTML=slideHTML
  94. }
  95.  
  96.  
  97. fadeshow.prototype.rotateimage=function(){
  98. if (this.pausecheck==1) //if pause onMouseover enabled, cache object
  99. var cacheobj=this
  100. if (this.mouseovercheck==1)
  101. setTimeout(function(){cacheobj.rotateimage()}, 100)
  102. else if (iebrowser&&dom||dom){
  103. this.resetit()
  104. var crossobj=this.tempobj=iebrowser? iebrowser[this.curcanvas] : document.getElementById(this.curcanvas)
  105. crossobj.style.zIndex++
  106. fadeclear[this.slideshowid]=setInterval("fadepic(fadearray["+this.slideshowid+"])",50)
  107. this.curcanvas=(this.curcanvas==this.canvasbase+"_0")? this.canvasbase+"_1" : this.canvasbase+"_0"
  108. }
  109. else{
  110. var ns4imgobj=document.images['defaultslide'+this.slideshowid]
  111. ns4imgobj.src=this.postimages[this.curimageindex].src
  112. }
  113. this.curimageindex=(this.curimageindex<this.postimages.length-1)? this.curimageindex+1 : 0
  114. }
  115.  
  116. fadeshow.prototype.resetit=function(){
  117. this.degree=10
  118. var crossobj=iebrowser? iebrowser[this.curcanvas] : document.getElementById(this.curcanvas)
  119. if (crossobj.filters&&crossobj.filters[0]){
  120. if (typeof crossobj.filters[0].opacity=="number") //if IE6+
  121. crossobj.filters(0).opacity=this.degree
  122. else //else if IE5.5-
  123. crossobj.style.filter="alpha(opacity="+this.degree+")"
  124. }
  125. else if (crossobj.style.MozOpacity)
  126. crossobj.style.MozOpacity=this.degree/101
  127. else if (crossobj.style.KhtmlOpacity)
  128. crossobj.style.KhtmlOpacity=obj.degree/100
  129. }
  130.  
  131.  
  132. fadeshow.prototype.startit=function(){
  133. var crossobj=iebrowser? iebrowser[this.curcanvas] : document.getElementById(this.curcanvas)
  134. this.populateslide(crossobj, this.curimageindex)
  135. if (this.pausecheck==1){ //IF SLIDESHOW SHOULD PAUSE ONMOUSEOVER
  136. var cacheobj=this
  137. var crossobjcontainer=iebrowser? iebrowser["master"+this.slideshowid] : document.getElementById("master"+this.slideshowid)
  138. crossobjcontainer.onmouseover=function(){cacheobj.mouseovercheck=1}
  139. crossobjcontainer.onmouseout=function(){cacheobj.mouseovercheck=0}
  140. }
  141. this.rotateimage()
  142. }
To jest wersja lo-fi głównej zawartości. Aby zobaczyć pełną wersję z większą zawartością, obrazkami i formatowaniem proszę kliknij tutaj.
Invision Power Board © 2001-2025 Invision Power Services, Inc.