WebSite X5Help Center

 
Rinaldo R.
Rinaldo R.
User

Effetto Neve  it

Author: Rinaldo R.
Visited 863, Followers 2, Shared 0  

Salve ragazzi in un topic qui ho trovato come inserire l'effetto neve sulla home page, ed è uscito bene, solo che quello che ho impostato ha anche diciamo il cumulo, cioè che a fine pagina si deposita la neve, e quindi vorrei togliere solo quel deposito in quanto si "impalla" e non scorre bene.

il sito è questo: www.rino-russo.it 

e questo è il codice html:

<script type="text/javascript"> var speed=33; // lower number for faster
var flakes=100; // number of flakes

var colour="#FFFFFF"; // colour of flakes
var slush=20; // set to '0' for no slush or otherwise set to height at which slush melts

/***************************\
* Let It Snow Effect *
*(c) 2004-6 mf2fm web-design*
* http://www.mf2fm.com/rv *
* DON'T EDIT BELOW THIS BOX *
\***************************/
var flks=new Array();
var flkx=new Array();
var flky=new Array();
var fldy=new Array();
var slss=new Array();
var slsh=new Array();
var swide, shigh;
window.onload=function() { if (document.getElementById) {
var b, s;
b=document.createElement("div");
s=b.style;
s.position="absolute";
b.setAttribute("id", "bod");
document.body.appendChild(b);
set_scroll();
set_width();
for (var i=0; i<flakes; i++) {
flks[i]=createDiv(3,3);
flkx[i]=3*Math.floor(Math.random()*swide/3);
flky[i]=Math.floor(Math.random()*shigh);
fldy[i]=2+Math.floor(Math.random()*4);
flks[i].style.left=flkx[i]+"px";
flks[i].style.top=flky[i]+"px";
b.appendChild(flks[i]);
}
setInterval("let_it_snow()", speed);
}}

function createDiv(height, width) {
var div=document.createElement("div");
div.style.position="absolute";
div.style.height=height+"px";
div.style.width=width+"px";
div.style.overflow="hidden";
div.style.backgroundColor=colour;
return (div);
}

window.onresize=set_width;
function set_width() {
if (document.documentElement && document.documentElement.clientWidth) {
swide=document.documentElement.clientWidth;
shigh=document.documentElement.clientHeight;
}
else if (typeof(self.innerHeight)=="number") {
swide=self.innerWidth;
shigh=self.innerHeight;
}
else if (document.body.clientWidth) {
swide=document.body.clientWidth;
shigh=document.body.clientHeight;
}
swide-=3;
if (slush) {
if (swide/3>slss.length) for (var i=slss.length; i<swide/3; i++) {
slss[i]=createDiv(3, 3);
slss[i].style.left=3*i+"px";
document.getElementById("bod").appendChild(slss[i]);
slsh[i]=3;
}
for (var i=0; i<swide/3; i++) slss[i].style.top=shigh-slsh[i]+"px";
}
}

window.onscroll=set_scroll;
function set_scroll() {
var sleft, sdown;
if (typeof(self.pageYOffset)=="number") {
sdown=self.pageYOffset;
sleft=self.pageXOffset;
}
else if (document.body.scrollTop || document.body.scrollLeft) {
sdown=document.body.scrollTop;
sleft=document.body.scrollLeft;
}
else if (document.documentElement && (document.documentElement.scrollTop || document.documentElement.scrollLeft)) {
sleft=document.documentElement.scrollLeft;
sdown=document.documentElement.scrollTop;
}
else {
sdown=0;
sleft=0;
}
var s=document.getElementById("bod").style;
s.top=sdown+"px";
s.left=sleft+"px";
}

function let_it_snow(c) {
var i, x, o=0;
for (i=0; i<flakes; i++) {
flky[i]+=fldy[i];
x=flkx[i]/3;
if (slush) o+=slsh[x];
if (flky[i]>=shigh-(slush?slsh[x]:0)) {
if (slush) {
if (x<swide && slsh[x]>slsh[x+1]+3) x++;
else if (x>0 && slsh[x]>slsh[x-1]+3) x--;
slss[x].style.top=shigh-(slsh[x]+=3)+"px";
slss[x].style.height=slsh[x]+"px";
}
flky[i]=0;
fldy[i]=2+Math.floor(Math.random()*4);
flkx[i]=3*Math.floor(Math.random()*swide/3);
flks[i].style.left=flkx[i]+"px";
}
flks[i].style.top=flky[i]+"px";
}
if (o>flakes*slush) {
for (i=0; i<swide/3; i++) if (slsh[i]>1) slsh[i]--;
set_width();
}
}

</script>

Posted on the
8 ANSWERS - 2 USEFUL
Claudio D.
Claudio D.
Moderator
Best User of the month PT

non l'ho provato ma se ho compreso...

metti 0 qui al posto di 20:

var slush=20;

Read more
Posted on the from Claudio D.
Rinaldo R.
Rinaldo R.
User
Author

Perfetto grazie!! (scusa non sono esperto di html)

Read more
Posted on the from Rinaldo R.
Claudio D.
Claudio D.
Moderator
Best User of the month PT

bene, ma ho solo tradotto "slush" wink

chiudi il post con "corretto" (spunta verde) , sulla risposta risolutiva...

grazie

Read more
Posted on the from Claudio D.
Giuseppe Guida
Giuseppe Guida
User

Rino, hai una foto in home di ben 6,51 MB! Pesantissima per il web. Ottimizzala in un click su https://tinypng.com/ e metti quella ottimizzata. 

ciao

Read more
Posted on the from Giuseppe Guida
Giuseppe Guida
Giuseppe Guida
User

Ops, non la puoi ottimizzare su tinypng.com in modo gratuito perchè la tua foto supera i 5 MB consentiti dalla versione free. Cerca sul web, troverai il modo di renderla più leggera. Ciao

Read more
Posted on the from Giuseppe Guida
Alberto B.
Alberto B.
User

Ciao a tutti... si effettivamente come dice giuseppe l'immagine sulla home è pesantina... da me parte sgranata...

Ho provato il codice-neve, funziona ma mi trema tutta la pagina ho sbagliato qualcosa ?

Read more
Posted on the from Alberto B.
Claudio D.
Claudio D.
Moderator
Best User of the month PT
Alberto B.
Ciao a tutti... si effettivamente come dice giuseppe l'immagine sulla home è pesantina... da me parte sgranata... Ho provato il codice-neve, funziona ma mi trema tutta la pagina ho sbagliato qualcosa ?

premesso che è un codice extra... magari va in conflitto con qualcosa sul tuo sito...

ti consiglio , se non vuoi usare l'oggetto predisposto da Incomedia 

https://market.websitex5.com/it/oggetti/anteprima/35ff1667-2938-42c1-827d-215b0e4fe77

o altri codici reperibili in rete ...

se non risolvi di aprire un post tutto tuo e di postare il link... 

Read more
Posted on the from Claudio D.
Alberto B.
Alberto B.
User

Grazie Claudio, ho risolto...

--> per Rinaldo R. scusami se mi sono inserito, ora puoi chiudere il tuo post

Read more
Posted on the from Alberto B.