Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> Płynne przejścia między obrazkami
Jokeer
post 11.04.2014, 21:28:40
Post #1





Grupa: Zarejestrowani
Postów: 21
Pomógł: 0
Dołączył: 2.06.2008

Ostrzeżenie: (0%)
-----


Cześć, mam taki kod, który zmienia co jakiś czas logo na mojej stronie. Niestety obrazki zmieniają się bez żadnego przejścia. Jak mogę zmodyfikować ten kod, żeby uzyskać efekt jakiegoś łagodnego przejścia?

  1. <script language="javascript">
  2.  
  3.  
  4. var delay=5000 //set delay in miliseconds
  5.  
  6. var curindex=0
  7.  
  8. var randomimages=new Array()
  9.  
  10. randomimages[0]="images1.jpg"
  11.  
  12. randomimages[1]="images2.jpg"
  13.  
  14. randomimages[2]="images3.jpg"
  15.  
  16. randomimages[3]="images4.jpg"
  17.  
  18. randomimages[4]="images5.jpg"
  19.  
  20. randomimages[5]="images6.jpg"
  21.  
  22. var preload=new Array()
  23.  
  24. for (n=0;n<randomimages.length;n++)
  25.  
  26. {
  27.  
  28. preload[n]=new Image()
  29.  
  30. preload[n].src=randomimages[n] //cycle('fade');
  31.  
  32.  
  33. }
  34.  
  35. document.write('<img name="defaultimage" src="'+randomimages[Math.floor(Math.random()*(randomimages.length))]
  36. +'">')
  37.  
  38. function rotateimage()
  39.  
  40. {
  41.  
  42. if (curindex==(tempindex=Math.floor(Math.random()*(randomimages.length))
  43. )){
  44.  
  45. curindex=curindex==0? 1 : curindex-1
  46.  
  47. }
  48.  
  49. else
  50.  
  51. curindex=tempindex
  52.  
  53. document.images.defaultimage.src=randomimages[curindex]
  54.  
  55. }
  56.  
  57. setInterval("rotateimage()",delay)
  58.  
  59. </script>


Dzięki i pozdrawiam wink.gif
Go to the top of the page
+Quote Post

Posty w temacie


Reply to this topicStart new topic
1 Użytkowników czyta ten temat (1 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Wersja Lo-Fi Aktualny czas: 19.06.2025 - 11:24