Neve de Natal
Neve de natal
by edgardleal
CSS
body{
background : black;
}
JavaScript
var img = "http://loktar00.github.io/JQuery-Snowfall/images/flake.png";
Flake = function(){
var self = this;
this.$img = $('<img />').attr('src', "http://loktar00.github.io/JQuery-Snowfall/images/flake.png")
.css('position', 'absolute')
.css('box-shadow','10px 10px 5px #0000')
.appendTo('body');
this.size = Math.round(Math.random() * 15) + 5;
this.x = Math.round(Math.random() * 200);
this.y = Math.round(Math.random() * -30);
this.xIncrement = 2;
this.yIncrement = Math.round(Math.random() * 2) + 1;
this.$img.css('width', self.size + 'px')
.css('height', self.size + 'px');
this.move = function(){
self.$img.css('top' , self.y + 'px')
.css('left', self.x + 'px');
if(self.y % 8==0)
self.xIncrement =
(Math.round(Math.random() * 4) - 2);
self.x = self.x + self.xIncrement;
self.y += self.yIncrement;
if(self.y > 500) self.y = 3;
if(self.x > 500) self.x = Math.round(Math.random() * 200);
};
setInterval(this.move, 100);
};
for(i = 0; i< 10; i++)
new Flake();