Foros del Web » Programando para Internet » Javascript »

efecto nieve

Estas en el tema de efecto nieve en el foro de Javascript en Foros del Web. como logro un efecto de nieve en mi pagina al estilo de esta http://blueprintds.com/2009/01/20/top-14-jquery-photo-slideshow-gallery-plugins/...
  #1 (permalink)  
Antiguo 10/12/2010, 05:34
Avatar de LuisCenardo  
Fecha de Ingreso: noviembre-2010
Ubicación: Salta
Mensajes: 221
Antigüedad: 13 años, 4 meses
Puntos: 3
efecto nieve

como logro un efecto de nieve en mi pagina al estilo de esta http://blueprintds.com/2009/01/20/top-14-jquery-photo-slideshow-gallery-plugins/
  #2 (permalink)  
Antiguo 10/12/2010, 06:19
Avatar de Ventru3  
Fecha de Ingreso: noviembre-2010
Ubicación: Disneylandia
Mensajes: 86
Antigüedad: 13 años, 4 meses
Puntos: 13
Respuesta: efecto nieve

Viendo el código fuente de la página lo podrías haber sacado.

Código HTML:
<script type="text/javascript">
var SNOW_Picture = "http://www.peters1.dk/billeder/snowflakes/snow1.gif"
var SNOW_no = 15;
var SNOW_browser_IE_NS;
var SNOW_browser_MOZ;
var SNOW_browser_IE7;
var SNOW_Time;
var SNOW_dx, SNOW_xp, SNOW_yp;
var SNOW_am, SNOW_stx, SNOW_sty; 
var i, SNOW_Browser_Width, SNOW_Browser_Height;
//SNOW_Browser_Height = 2000;
SNOW_dx = new Array();
SNOW_xp = new Array();
SNOW_yp = new Array();
SNOW_am = new Array();
SNOW_stx = new Array();
SNOW_sty = new Array();
function SNOW_Weather() 
{ 

for (i = 0; i < SNOW_no; ++ i) 
{ 
	SNOW_yp[i] += SNOW_sty[i];
	if (SNOW_yp[i] > SNOW_Browser_Height-50) 
	{
		SNOW_xp[i] = Math.random()*(SNOW_Browser_Width-SNOW_am[i]-30);
		SNOW_yp[i] = 0;
		SNOW_stx[i] = 0.02 + Math.random()/10;
		SNOW_sty[i] = 0.7 + Math.random();
	}
	SNOW_dx[i] += SNOW_stx[i];
	document.getElementById("SNOW_flake"+i).style.top=SNOW_yp[i]+"px";
	document.getElementById("SNOW_flake"+i).style.left=SNOW_xp[i] + SNOW_am[i]*Math.sin(SNOW_dx[i])+"px";
}
SNOW_Time = setTimeout("SNOW_Weather()", 10);
}
jQuery(document).ready( function() {

////////////////////////////////////////////////////////////////

// Javascript made by Rasmus - http://www.peters1.dk //

////////////////////////////////////////////////////////////////
SNOW_browser_IE_NS = (document.body.clientHeight) ? 1 : 0;
SNOW_browser_MOZ = (self.innerWidth) ? 1 : 0;
SNOW_browser_IE7 = (document.documentElement.clientHeight) ? 1 : 0;

if (SNOW_browser_IE_NS)
{
	SNOW_Browser_Width = document.body.clientWidth;
	SNOW_Browser_Height = document.body.clientHeight;
}
else if (SNOW_browser_MOZ)
{
	SNOW_Browser_Width = self.innerWidth - 20;
	SNOW_Browser_Height = self.innerHeight;
}
else if (SNOW_browser_IE7)
{
	SNOW_Browser_Width = document.documentElement.clientWidth;
	SNOW_Browser_Height = document.documentElement.clientHeight;
}

for (i = 0; i < SNOW_no; ++ i) 
{ 
	SNOW_dx[i] = 0; 
	SNOW_xp[i] = Math.random()*(SNOW_Browser_Width-50);
	SNOW_yp[i] = Math.random()*SNOW_Browser_Height;
	SNOW_am[i] = Math.random()*20; 
	SNOW_stx[i] = 0.02 + Math.random()/10;
	SNOW_sty[i] = 0.7 + Math.random();
	if (i == 0) jQuery('body').prepend("<\div id=\"SNOW_flake"+ i +"\" style=\"position: absolute; z-index:200; visibility: visible; top: 15px; left: 15px;\"><a href=\"http://www.spiders-design.co.uk\" target=\"_blank\"><\img src=\""+SNOW_Picture+"\" border=\"0\"></a><\/div>");

	else jQuery('body').prepend("<\div id=\"SNOW_flake"+ i +"\" style=\"position: absolute; z-index: 200; visibility: visible; top: 15px; left: 15px;\"><\img src=\""+SNOW_Picture+"\" border=\"0\"><\/div>");

}
SNOW_Weather();

});
</script> 
Ese es el de la pagina, tienes que pegarlo entre las etiquetas head.
  #3 (permalink)  
Antiguo 10/12/2010, 06:56
Avatar de LuisCenardo  
Fecha de Ingreso: noviembre-2010
Ubicación: Salta
Mensajes: 221
Antigüedad: 13 años, 4 meses
Puntos: 3
Respuesta: efecto nieve

disculpa, ja ni pense en eso,.. gracias.. y una pregunta mas.. em.. en que parte del codigo deberia ser modificado para que no caigan tan lentas, sino mas rapido.. y en lo posible mas..
  #4 (permalink)  
Antiguo 10/12/2010, 14:11
Avatar de Ventru3  
Fecha de Ingreso: noviembre-2010
Ubicación: Disneylandia
Mensajes: 86
Antigüedad: 13 años, 4 meses
Puntos: 13
Respuesta: efecto nieve

Modifica esta linea:
Código HTML:
SNOW_Time = setTimeout("SNOW_Weather()", 10);

Etiquetas: efecto, nieve
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 21:44.