Part of Slepp's ProjectsPastebinTURLImagebinFilebin
Feedback -- English French German Japanese
Create Upload Newest Tools Donate

Advertising

Paste Description for Snow Effect

Snow flask Javascript
Read: http://tech-buzz.net/2006/12/17/give-snow-effect-to-your-blog/

Snow Effect
Sunday, December 17th, 2006 at 3:59:31pm UTC 

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

advertising

Update the Post

Either update this post and resubmit it with changes, or make a new post.

You may also comment on this post.

update paste below
details of the post (optional)

Note: Only the paste content is required, though the following information can be useful to others.

Save name / title?

(space separated, optional)



Please note that information posted here will not expire by default. If you do not want it to expire, please set the expiry time above. If it is set to expire, web search engines will not be allowed to index it prior to it expiring. Items that are not marked to expire will be indexable by search engines. Be careful with your passwords. All illegal activities will be reported and any information will be handed over to the authorities, so be good.

comments powered by Disqus
worth-right