Advertisement
reijeo

block rain mf2fm

Jul 16th, 2022
277
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.82 KB | None | 0 0
  1. <script type="text/javascript">
  2. // <![CDATA[
  3. var colour="#cc99ff"; // colours of drops
  4. var border="#6600ff"; // colour of border
  5. var speed=40; // speed of animation, lower is faster
  6. var size=20; // size of blocks
  7. var drops=40; // number of raindrops
  8.  
  9. /***************************\
  10. * Block Rain Graphic Effect *
  11. *(c)2005-12 mf2fm web-design*
  12. * http://www.mf2fm.com/rv *
  13. * DON'T EDIT BELOW THIS BOX *
  14. \***************************/
  15. var swide, shigh;
  16. var blox=new Array();
  17. var blok=new Array();
  18. var boddie;
  19.  
  20. window.onload=function() { if (document.getElementById) {
  21. var i, d, s;
  22. boddie=document.createElement("div");
  23. s=boddie.style;
  24. s.position="fixed";
  25. s.top="0px";
  26. s.left="0px";
  27. s.width="1px";
  28. s.height="1px";
  29. s.overflow="visible";
  30. s.backgroundColor="transparent";
  31. document.body.appendChild(boddie);
  32. set_width();
  33. for (i=0; i<drops; i++) {
  34. d=document.createElement("div");
  35. s=d.style;
  36. s.width=size+"px";
  37. s.height=size+"px";
  38. s.overflow="hidden";
  39. s.position="absolute";
  40. s.visibility="hidden";
  41. s.backgroundColor=colour;
  42. s.border="1px solid "+border;
  43. blox[i]=-1;
  44. blok[i]=d;
  45. boddie.appendChild(blok[i]);
  46. }
  47. size+=4;
  48. mainblock(0);
  49. }}
  50.  
  51. function mainblock(r) {
  52. var t, l;
  53. t=4+size*Math.floor(Math.random()*(shigh-size)/size);
  54. l=4+size*Math.floor(Math.random()*(swide-size)/size);
  55. blok[r].style.left=l+"px";
  56. blok[r].style.top=t+"px";
  57. blox[r]=11;
  58. blok[r].style.visibility="visible";
  59. subblock(r);
  60. setTimeout("mainblock("+(++r%drops)+")", speed);
  61. }
  62.  
  63. function subblock(r) {
  64. if (--blox[r]>-1) {
  65. if (navigator.appName=="Microsoft Internet Explorer") blok[r].style.filter="alpha(opacity="+blox[r]*10+")";
  66. else blok[r].style.opacity=blox[r]/10;
  67. setTimeout("subblock("+r+")", speed*drops/12);
  68. }
  69. else blok[r].style.visibility="hidden";
  70. }
  71.  
  72. window.onresize=set_width;
  73. function set_width() {
  74. var sw_min=999999;
  75. var sh_min=999999;
  76. if (document.documentElement && document.documentElement.clientWidth) {
  77. if (document.documentElement.clientWidth>0) sw_min=document.documentElement.clientWidth;
  78. if (document.documentElement.clientHeight>0) sh_min=document.documentElement.clientHeight;
  79. }
  80. if (typeof(self.innerWidth)!="undefined" && self.innerWidth) {
  81. if (self.innerWidth>0 && self.innerWidth<sw_min) sw_min=self.innerWidth;
  82. if (self.innerHeight>0 && self.innerHeight<sh_min) sh_min=self.innerHeight;
  83. }
  84. if (document.body.clientWidth) {
  85. if (document.body.clientWidth>0 && document.body.clientWidth<sw_min) sw_min=document.body.clientWidth;
  86. if (document.body.clientHeight>0 && document.body.clientHeight<sh_min) sh_min=document.body.clientHeight;
  87. }
  88. if (sw_min==999999 || sh_min==999999) {
  89. sw_min=800;
  90. sh_min=600;
  91. }
  92. swide=sw_min;
  93. shigh=sh_min;
  94. }
  95. // ]]>
  96. </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement