TICKOONA

اضافه بالونات غلي بلوجر تتحرك مع مرور الماوس

Jul 22nd, 2018
33
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.41 KB | None | 0 0
  1. <script type="text/javascript">
  2. var colours=new Array("#F781BE", "#F781BE", "#F781BE", "#F781BE", "#F781BE"); // warna untuk border-top, border-right, border-bottom, border-left dan background gelembung
  3. var bubbles=100; // jumlah maksmal gelembung
  4. var x=ox=400;
  5. var y=oy=300;
  6. var swide=800;
  7. var shigh=600;
  8. var sleft=sdown=0;
  9. var bubb=new Array();
  10. var bubbx=new Array();
  11. var bubby=new Array();
  12. var bubbs=new Array();
  13. window.onload=function() { if (document.getElementById) {
  14. var rats, div;
  15. for (var i=0; i<bubbles; i++) {
  16. rats=createDiv("3px", "3px");
  17. rats.style.visibility="hidden";
  18. div=createDiv("auto", "auto");
  19. rats.appendChild(div);
  20. div=div.style;
  21. div.top="1px";
  22. div.left="0px";
  23. div.bottom="1px";
  24. div.right="0px";
  25. div.borderLeft="1px solid "+colours[3];
  26. div.borderRight="1px solid "+colours[1];
  27. div=createDiv("auto", "auto");
  28. rats.appendChild(div);
  29. div=div.style;
  30. div.top="0px";
  31. div.left="1px";
  32. div.right="1px";
  33. div.bottom="0px"
  34. div.borderTop="1px solid "+colours[0];
  35. div.borderBottom="1px solid "+colours[2];
  36. div=createDiv("auto", "auto");
  37. rats.appendChild(div);
  38. div=div.style;
  39. div.left="1px";
  40. div.right="1px";
  41. div.bottom="1px";
  42. div.top="1px";
  43. div.backgroundColor=colours[4];
  44. div.opacity=0.5;
  45. if (document.all) div.filter="alpha(opacity=50)";
  46. document.body.appendChild(rats);
  47. bubb[i]=rats.style;
  48. }
  49. set_scroll();
  50. set_width();
  51. bubble();
  52. }}
  53.  
  54. function bubble() {
  55. var c;
  56. if (x!=ox || y!=oy){
  57. ox=x;
  58. oy=y;
  59. for (c=0; c<bubbles; c++) if (!bubby[c]) {
  60. bubb[c].left=(bubbx[c]=x)+"px";
  61. bubb[c].top=(bubby[c]=y)+"px";
  62. bubb[c].width="3px";
  63. bubb[c].height="3px"
  64. bubb[c].visibility="visible";
  65. bubbs[c]=3;
  66. break;
  67. }
  68. }
  69.  
  70. for (c=0; c<bubbles; c++) if (bubby[c]) update_bubb(c);
  71. setTimeout("bubble()", 40);
  72. }
  73.  
  74. function update_bubb(i) {
  75. if (bubby[i]) {
  76. bubby[i]-=bubbs[i]/2+i%2;
  77. bubbx[i]+=(i%5-2)/5;
  78. if (bubby[i]>sdown && bubbx[i]>0) {
  79. if (Math.random()<bubbs[i]/shigh*2 && bubbs[i]++<8) {
  80. bubb[i].width=bubbs[i]+"px";
  81. bubb[i].height=bubbs[i]+"px";
  82. }
  83. bubb[i].top=bubby[i]+"px";
  84. bubb[i].left=bubbx[i]+"px";
  85. }
  86. else {
  87. bubb[i].visibility="hidden";
  88. bubby[i]=0;
  89. return;
  90. }
  91. }
  92. }
  93. document.onmousemove=mouse;
  94.  
  95. function mouse(e) {
  96. set_scroll();
  97. y=(e)?e.pageY:event.y+sleft;
  98. x=(e)?e.pageX:event.x+sdown;
  99. }
  100.  
  101. window.onresize=set_width;
  102.  
  103. function set_width() {
  104. if (document.documentElement && document.documentElement.clientWidth) {
  105. swide=document.documentElement.clientWidth;
  106. shigh=document.documentElement.clientHeight;
  107. }
  108. else if (typeof(self.innerHeight)=="number") {
  109. swide=self.innerWidth;
  110. shigh=self.innerHeight;
  111. }
  112. else if (document.body.clientWidth) {
  113. swide=document.body.clientWidth;
  114. shigh=document.body.clientHeight;
  115. }
  116. else {
  117. swide=800;
  118. shigh=600;
  119. }
  120. }
  121.  
  122. window.onscroll=set_scroll;
  123.  
  124. function set_scroll() {
  125. if (typeof(self.pageYOffset)=="number") {
  126. sdown=self.pageYOffset;
  127. sleft=self.pageXOffset;
  128. }
  129. else if (document.body.scrollTop || document.body.scrollLeft) {
  130. sdown=document.body.scrollTop;
  131. sleft=document.body.scrollLeft;
  132. }
  133. else if (document.documentElement && (document.documentElement.scrollTop || document.documentElement.scrollLeft)) {
  134. sleft=document.documentElement.scrollLeft;
  135. sdown=document.documentElement.scrollTop;
  136. }
  137. else {
  138. sdown=0;
  139. sleft=0;
  140. }
  141. }
  142.  
  143. function createDiv(height, width) {
  144. var div=document.createElement("div");
  145. div.style.position="absolute";
  146. div.style.height=height;
  147. div.style.width=width;
  148. div.style.overflow="hidden";
  149. return (div);
  150. }
  151.  
  152. </script>
Add Comment
Please, Sign In to add comment