Ver Mensaje Individual
  #1  
Antiguo 08-02-2009
Deiv Deiv is offline
Miembro
 
Registrado: jul 2005
Ubicación: La Paz - Bolivia
Posts: 364
Reputación: 19
Deiv Va por buen camino
Exclamation Script Efecto Nieve retarda GIFs Animados

Este efecto lo vi por las fechas de Navidad, y buscando en Google, encontré otro tipo de efecto NIEVE, aquellos que con una imagen (a elección) se podía observar este efecto de caida, imagino que lo conocen.
Pero este, par mi era nuevo nya que caía solo pixels, por ello quise incluir en el diseño de mi página el mismo.
¿Alguien podría explicarme por favor por qué este JScript? ralentiza el cargado de página?, verán estoy probando en Casa, aún no lo he subido a Internet, tengo algunas imágenes PNG puestas, un Video Flash SWF, un par de otros JScripts, y otro par de Gifs Animados.
Pude observar que si quito este script del <head> de mi HTML, todo funciona Ok, pero con este puesto encima, se mueven muy lentos los Gifs Animados, las marquesinas e inclusive al pasar por el Menú hecho en CSS se puede observar esta ralentización.
Código PHP:
if  ((document.getElementById) && 
window.addEventListener || window.attachEvent){

(function(){

//Configure here.

var num 40;   //Number of flakes
var timer 30//setTimeout speed. Varies on different comps
var enableinNS6 //Enable script in NS6/Mozilla? Snow animation could be slow in those browsers. (1=yes, 0=no).

//End.

var = [];
var 
= [];
var 
fall = [];
var 
theFlakes = [];
var 
sfs = [];
var 
step = [];
var 
currStep = [];
var 
h,w,r;
var 
document;
var 
pix "px";
var 
domWw = (typeof window.innerWidth == "number");
var 
domSy = (typeof window.pageYOffset == "number");
var 
idx d.getElementsByTagName('div').length;

if (
d.documentElement.style && 
typeof d.documentElement.style.MozOpacity == "string")
num 12;

for (
0numi++){
sfs[i] = Math.round(Math.random() * 1);

document.write('<div id="flake'+(idx+i)+'" style="position:absolute;top:0px;left:0px;width:'
+sfs[i]+'px;height:'+sfs[i]+'px;background-color:#ffffff;font-size:'+sfs[i]+'px"><\/div>');

currStep[i] = 0;
fall[i] = (sfs[i] == 1)?
Math.round(Math.random() * 2): Math.round(Math.random() * 2);
step[i] = (sfs[i] == 1)?
0.05 Math.random() * 0.1 0.05 Math.random() * 0.05 ;
}


if (
domWwwindow;
else{ 
  if (
d.documentElement && 
  
typeof d.documentElement.clientWidth == "number" && 
  
d.documentElement.clientWidth != 0)
  
d.documentElement;
 else{ 
  if (
d.body && 
  
typeof d.body.clientWidth == "number")
  
d.body;
 }
}


function 
winsize(){
var 
oh,sy,ow,sx,rh,rw;
if (
domWw){
  if (
d.documentElement && d.defaultView && 
  
typeof d.defaultView.scrollMaxY == "number"){
  
oh d.documentElement.offsetHeight;
  
sy d.defaultView.scrollMaxY;
  
ow d.documentElement.offsetWidth;
  
sx d.defaultView.scrollMaxX;
  
rh oh-sy;
  
rw ow-sx;
 }
 else{
  
rh r.innerHeight;
  
rw r.innerWidth;
 }
rh 2;  
rw 2
}
else{
r.clientHeight 2
r.clientWidth 2
}
}


function 
scrl(yx){
var 
y,x;
if (
domSy){
 
r.pageYOffset;
 
r.pageXOffset;
 }
else{
 
r.scrollTop;
 
r.scrollLeft;
 }
return (
yx == 0)?y:x;
}


function 
snow(){
var 
dy,dx;

for (
0numi++){
 
dy fall[i];
 
dx fall[i] * Math.cos(currStep[i]);

 
y[i]+=dy;
 
x[i]+=dx

 if (
x[i] >= || y[i] >= h){
  
y[i] = -10;
  
x[i] = Math.round(Math.random() * w);
  
fall[i] = (sfs[i] == 1)?
  
Math.round(Math.random() * 2): Math.round(Math.random() * 2);
  
step[i] = (sfs[i] == 1)?
  
0.05 Math.random() * 0.1 0.05 Math.random() * 0.05 ;
 }
 
 
theFlakes[i].top y[i] + scrl(0) + pix;
 
theFlakes[i].left x[i] + scrl(1) + pix;

 
currStep[i]+=step[i];
}
setTimeout(snow,timer);
}


function 
init(){
winsize();
for (
0numi++){
 
theFlakes[i] = document.getElementById("flake"+(idx+i)).style;
 
y[i] = Math.round(Math.random()*h);
 
x[i] = Math.round(Math.random()*w);
}
snow();
}


if (
window.addEventListener){
 
window.addEventListener("resize",winsize,false);
 
window.addEventListener("load",init,false);
}  
else if (
window.attachEvent){
 
window.attachEvent("onresize",winsize);
 
window.attachEvent("onload",init);


})();
}
//End. 
Una ayuda por favor?
Responder Con Cita