Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> [JS] Płatki śniegu na stronie - problem, platki pojawiaja sie do ok 70% strony, nizej nie ma
sw04
post
Post #1





Grupa: Zarejestrowani
Postów: 21
Pomógł: 0
Dołączył: 15.11.2005
Skąd: ZaBrzE

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


taki problem mam
mam skrypt ktory "wypuszcza" z gory strony platki sniegu. problem w tym ze zamiast na samym dole to traca sie one gdzies po ok. 70%. tzn przez pierwsze 70% strony platki sa, nizej juz nei (IMG:http://forum.php.pl/style_emoticons/default/blinksmiley.gif)
da rade zrobic zeby pokazywaly sie na calej stronie? (IMG:http://forum.php.pl/style_emoticons/default/sadsmiley02.gif)

zamieszczam kod (IMG:http://forum.php.pl/style_emoticons/default/smile.gif)

pozdrawiam

ps. nie ma przycisku do pokazywania JS wiec uzylem opcji do php



  1. <?php
  2. <script language="JavaScript1.2">
  3.  
  4. /*
  5. Snow Effect Script
  6. Submitted by Altan d.o.o. (snow@altan.hr, <a href=\"http://www.altan.hr/snow/index.html)\" target=\"_blank\">http://www.altan.hr/snow/index.html)</a>
  7. Permission granted to Dynamicdrive.com to feature script in archive
  8. For full source code to this script, visit <a href=\"http://dynamicdrive.com\" target=\"_blank\">http://dynamicdrive.com</a>
  9. */
  10.  
  11.  
  12. //Configure below to change URL path to the snow image
  13. var snowsrc="http://img506.imageshack.us/img506/4899/snieg5cg.gif"
  14. // Configure below to change number of snow to render
  15. var no = 10;
  16.  
  17. var ns4up = (document.layers) ? 1 : 0; // browser sniffer
  18. var ie4up = (document.all) ? 1 : 0;
  19. var ns6up = (document.getElementById&&!document.all) ? 1 : 0;
  20.  
  21. var dx, xp, yp; // coordinate and position variables
  22. var am, stx, sty; // amplitude and step variables
  23. var i, doc_width = 1024, doc_height = 768;
  24.  
  25. if (ns4up||ns6up) {
  26. doc_width = self.innerWidth;
  27. doc_height = self.innerHeight;
  28. } else if (ie4up) {
  29. doc_width = document.body.clientWidth;
  30. doc_height = document.body.clientHeight;
  31. }
  32.  
  33. dx = new Array();
  34. xp = new Array();
  35. yp = new Array();
  36. am = new Array();
  37. stx = new Array();
  38. sty = new Array();
  39.  
  40. for (= 0; i < no; ++ i) {
  41. dx[i] = 0; // set coordinate variables
  42. xp[i] = Math.random()*(doc_width-10); // set position variables
  43. yp[i] = Math.random()*doc_height;
  44. am[i] = Math.random()*20; // set amplitude variables
  45. stx[i] = 0.02 + Math.random()/10; // set step variables
  46. sty[i] = 0.+ Math.random(); // set step variables
  47. if (ns4up) { // set layers
  48. if (== 0) {
  49. document.write("<layer name=\"dot"+ i +"\" left=\"15\" top=\"15\" visibility=\"show\"><a href=\"http://dynamicdrive.com/\"><img src='"+snowsrc+"' border=\"0\"></a></layer>");
  50. } else {
  51. document.write("<layer name=\"dot"+ i +"\" left=\"15\" top=\"15\" visibility=\"show\"><img src='"+snowsrc+"' border=\"0\"></layer>");
  52. }
  53. } else if (ie4up||ns6up) {
  54. if (== 0) {
  55. document.write("<div id=\"dot"+ i +"\" style=\"POSITION: absolute; Z-INDEX: "+ i +"; VISIBILITY: visible; TOP: 15px; LEFT: 15px;\"><a href=\"http://dynamicdrive.com\"><img src='"+snowsrc+"' border=\"0\"></a></div>");
  56. } else {
  57. document.write("<div id=\"dot"+ i +"\" style=\"POSITION: absolute; Z-INDEX: "+ i +"; VISIBILITY: visible; TOP: 15px; LEFT: 15px;\"><img src='"+snowsrc+"' border=\"0\"></div>");
  58. }
  59. }
  60. }
  61.  
  62. function snowNS() { // Netscape main animation function
  63. for (= 0; i < no; ++ i) { // iterate for every dot
  64. yp[i] += sty[i];
  65. if (yp[i] > doc_height-50) {
  66. xp[i] = Math.random()*(doc_width-am[i]-30);
  67. yp[i] = 0;
  68. stx[i] = 0.02 + Math.random()/10;
  69. sty[i] = 0.+ Math.random();
  70. doc_width = self.innerWidth;
  71. doc_height = self.innerHeight;
  72. }
  73. dx[i] += stx[i];
  74. document.layers["dot"+i].top = yp[i];
  75. document.layers["dot"+i].left = xp[i] + am[i]*Math.sin(dx[i]);
  76. }
  77. setTimeout("snowNS()", 10);
  78. }
  79.  
  80. function snowIE_NS6() { // IE and NS6 main animation function
  81. for (= 0; i < no; ++ i) { // iterate for every dot
  82. yp[i] += sty[i];
  83. if (yp[i] > doc_height-50) {
  84. xp[i] = Math.random()*(doc_width-am[i]-10);
  85. yp[i] = 0;
  86. stx[i] = 0.02 + Math.random()/10;
  87. sty[i] = 0.+ Math.random();
  88. doc_width = ns6up?window.innerWidth : document.body.clientWidth;
  89. doc_height = ns6up?window.innerHeight : document.body.clientHeight;
  90. }
  91. dx[i] += stx[i];
  92. if (ie4up){
  93. document.all["dot"+i].style.pixelTop = yp[i];
  94. document.all["dot"+i].style.pixelLeft = xp[i] + am[i]*Math.sin(dx[i]);
  95. }
  96. else if (ns6up){
  97. document.getElementById("dot"+i).style.top=yp[i];
  98. document.getElementById("dot"+i).style.left=xp[i] + am[i]*Math.sin(dx[i]);
  99. }
  100. }
  101. setTimeout("snowIE_NS6()", 10);
  102. }
  103.  
  104. if (ns4up) {
  105. snowNS();
  106. } else if (ie4up||ns6up) {
  107. snowIE_NS6();
  108. }
  109.  
  110. </script>
  111. ?>


Ten post edytował sw04 21.12.2007, 15:50:11
Go to the top of the page
+Quote Post
Sadu2
post
Post #2





Grupa: Zarejestrowani
Postów: 229
Pomógł: 13
Dołączył: 31.05.2007

Ostrzeżenie: (10%)
X----


Nie znam sie na js, ale czy tu sie nie ustala czegos?

  1. <?php
  2. var i, doc_width = 1024, doc_height = 768;
  3. ?>
Go to the top of the page
+Quote Post
xbigos
post
Post #3





Grupa: Zarejestrowani
Postów: 239
Pomógł: 27
Dołączył: 13.07.2005
Skąd: Jarocin

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


Kod
<?php
var i, doc_width = 1024, doc_height = 768;
?>

zmien doc_height na 786
Tez za dobry w js-ie nie jestem:) ale wydaje mi sie ze powinno pomóc
Go to the top of the page
+Quote Post
sw04
post
Post #4





Grupa: Zarejestrowani
Postów: 21
Pomógł: 0
Dołączył: 15.11.2005
Skąd: ZaBrzE

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


niestety, zmiana tego parametru niczego nie zmienia - snieg caly czas spada do ok 70% strony... (IMG:http://forum.php.pl/style_emoticons/default/sad.gif)
Go to the top of the page
+Quote Post
dadexix
post
Post #5





Grupa: Zarejestrowani
Postów: 439
Pomógł: 21
Dołączył: 28.06.2007
Skąd: Bielsko-Biała

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


Cytat
Kod
<?php
var i, doc_width = 1024, doc_height = 768;
?>

zmien doc_height na 786
czy po tej zmianie zmieniła się "ilość" śniegu? dokładniej mówiąc czy jest cały czas tyle samo śniegu czy więcej śniegu o 20px strony?
Go to the top of the page
+Quote Post
sw04
post
Post #6





Grupa: Zarejestrowani
Postów: 21
Pomógł: 0
Dołączył: 15.11.2005
Skąd: ZaBrzE

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


Cytat(dadexix @ 21.12.2007, 19:18:02 ) *
czy po tej zmianie zmieniła się "ilość" śniegu? dokładniej mówiąc czy jest cały czas tyle samo śniegu czy więcej śniegu o 20px strony?


wstawialem tam rozne liczby (1, 700, 1000, 10000) i nie zauwazylem zbytniej roznicy roznicy - byc moze jest taka mala... (IMG:http://forum.php.pl/style_emoticons/default/sadsmiley02.gif)
Go to the top of the page
+Quote Post
Chrom
post
Post #7





Grupa: Zarejestrowani
Postów: 240
Pomógł: 17
Dołączył: 28.12.2005
Skąd: Warszawa

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


Problem tkwi tutaj
  1. <?php
  2. if (yp[i] > doc_height-50)
  3. ?>

masz to w dwóch miejscach zmień 50 na 5

Ten post edytował Chrom 21.12.2007, 21:34:10
Go to the top of the page
+Quote Post
sw04
post
Post #8





Grupa: Zarejestrowani
Postów: 21
Pomógł: 0
Dołączył: 15.11.2005
Skąd: ZaBrzE

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


Cytat(Chrom @ 21.12.2007, 21:33:49 ) *
Problem tkwi tutaj
  1. <?php
  2. if (yp[i] > doc_height-50)
  3. ?>

masz to w dwóch miejscach zmień 50 na 5


teraz, wydaje mi sie, ze leca z 2-3cm nizej, ale dalej nie na sam dol (IMG:http://forum.php.pl/style_emoticons/default/blinksmiley.gif)
Go to the top of the page
+Quote Post
Chrom
post
Post #9





Grupa: Zarejestrowani
Postów: 240
Pomógł: 17
Dołączył: 28.12.2005
Skąd: Warszawa

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


to daj + 50
pokombinuj

Ten post edytował Chrom 21.12.2007, 22:41:47
Go to the top of the page
+Quote Post
Liko
post
Post #10





Grupa: Zarejestrowani
Postów: 436
Pomógł: 6
Dołączył: 8.11.2003
Skąd: Szczecin

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


  1. <script type="text/javascript">
  2.  
  3. /******************************************
  4. * Snow Effect Script- By Altan d.o.o. (http://www.altan.hr/snow/index.html)
  5. * Visit Dynamic Drive DHTML code library (http://www.dynamicdrive.com/) for full source code
  6. * Last updated Nov 9th, 05' by DD. This notice must stay intact for use
  7. ******************************************/
  8.  
  9. //Configure below to change URL path to the snow image
  10. var snowsrc="http://img506.imageshack.us/img506/4899/snieg5cg.gif"
  11. // Configure below to change number of snow to render
  12. var no = 10;
  13. // Configure whether snow should disappear after x seconds (0=never):
  14. var hidesnowtime = 0;
  15. // Configure how much snow should drop down before fading ("windowheight" or "pageheight")
  16. var snowdistance = "pageheight";
  17.  
  18. ///////////Stop Config//////////////////////////////////
  19.  
  20. var ie4up = (document.all) ? 1 : 0;
  21. var ns6up = (document.getElementById&&!document.all) ? 1 : 0;
  22.  
  23. function iecompattest(){
  24. return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
  25. }
  26.  
  27. var dx, xp, yp; // coordinate and position variables
  28. var am, stx, sty; // amplitude and step variables
  29. var i, doc_width = 800, doc_height = 600;
  30.  
  31. if (ns6up) {
  32. doc_width = self.innerWidth;
  33. doc_height = self.innerHeight;
  34. } else if (ie4up) {
  35. doc_width = iecompattest().clientWidth;
  36. doc_height = iecompattest().clientHeight;
  37. }
  38.  
  39. dx = new Array();
  40. xp = new Array();
  41. yp = new Array();
  42. am = new Array();
  43. stx = new Array();
  44. sty = new Array();
  45. snowsrc=(snowsrc.indexOf("dynamicdrive.com")!=-1)? "snow.gif" : snowsrc
  46. for (i = 0; i < no; ++ i) {
  47. dx[i] = 0; // set coordinate variables
  48. xp[i] = Math.random()*(doc_width-50); // set position variables
  49. yp[i] = Math.random()*doc_height;
  50. am[i] = Math.random()*20; // set amplitude variables
  51. stx[i] = 0.02 + Math.random()/10; // set step variables
  52. sty[i] = 0.7 + Math.random(); // set step variables
  53. if (ie4up||ns6up) {
  54. if (i == 0) {
  55. document.write("<div id=\"dot"+ i +"\" style=\"POSITION: absolute; Z-INDEX: "+ i +"; VISIBILITY: visible; TOP: 15px; LEFT: 15px;\"><a href=\"http://dynamicdrive.com\"><img src='"+snowsrc+"' border=\"0\"><\/a><\/div>");
  56. } else {
  57. document.write("<div id=\"dot"+ i +"\" style=\"POSITION: absolute; Z-INDEX: "+ i +"; VISIBILITY: visible; TOP: 15px; LEFT: 15px;\"><img src='"+snowsrc+"' border=\"0\"><\/div>");
  58. }
  59. }
  60. }
  61.  
  62. function snowIE_NS6() { // IE and NS6 main animation function
  63. doc_width = ns6up?window.innerWidth-10 : iecompattest().clientWidth-10;
  64. doc_height=(window.innerHeight && snowdistance=="windowheight")? window.innerHeight : (ie4up && snowdistance=="windowheight")? iecompattest().clientHeight : (ie4up && !window.opera && snowdistance=="pageheight")? iecompattest().scrollHeight : iecompattest().offsetHeight;
  65. for (i = 0; i < no; ++ i) { // iterate for every dot
  66. yp[i] += sty[i];
  67. if (yp[i] > doc_height-50) {
  68. xp[i] = Math.random()*(doc_width-am[i]-30);
  69. yp[i] = 0;
  70. stx[i] = 0.02 + Math.random()/10;
  71. sty[i] = 0.7 + Math.random();
  72. }
  73. dx[i] += stx[i];
  74. document.getElementById("dot"+i).style.top=yp[i]+"px";
  75. document.getElementById("dot"+i).style.left=xp[i] + am[i]*Math.sin(dx[i])+"px";
  76. }
  77. snowtimer=setTimeout("snowIE_NS6()", 10);
  78. }
  79.  
  80. function hidesnow(){
  81. if (window.snowtimer) clearTimeout(snowtimer)
  82. for (i=0; i<no; i++) document.getElementById("dot"+i).style.visibility="hidden"
  83. }
  84.  
  85.  
  86. if (ie4up||ns6up){
  87. snowIE_NS6();
  88. if (hidesnowtime>0)
  89. setTimeout("hidesnow()", hidesnowtime*1000)
  90. }
  91.  


Ten post edytował Liko 21.12.2007, 22:43:31
Go to the top of the page
+Quote Post

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

 



RSS Aktualny czas: 25.08.2025 - 04:17