-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsvg3.js
85 lines (68 loc) · 1.79 KB
/
svg3.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
/****************************
Author:Jasper Mishra,
File: svg.js
Description: Creates rain droplets and randomizes their position.
Runs animation in infinite duration
***************************/
function moveCloud2() {
$("#cloudsContainer2").animate({
'left':'+=2240px',
},87000,function(){
var left=$("#cloudsContainer2").css('left');
if(left=='0px'){
moveCloud2();
}
else if(left=='2240px'){
$("#cloudsContainer2").css({'left':'-2240px'});
randomizeCloud2Position();
moveCloud2();
}
});
}
function randomizeCloud2Position() {
var clouds=$("#cloudsContainer2 img");
clouds.each(function(i){
$(this).css({'top':Math.random()*3+'em'});
});
}
jQuery(document).ready(function($)
{
randomizeCloud2Position();
moveCloud2();
for(var i=0;i<30;i++)
{
var droplets=[]; //rain droplets array
//creating and storing droplets
var droplet=$("<div>").addClass('droplet');
setDropletShapePosition(droplet);
$("body").append(droplet);
droplets.push(droplet);
}
var droplets=$(".droplet");
droplets.each(function(){
splashVanish($(this));
});
});
function setDropletShapePosition(droplet) {
var equalDim=Math.random()*6;
var r=(Math.random()*10)+10;
droplet.css({
'webkit-border-radius':r+'em',
'moz-border-radius':r+'em',
'o-border-radius':r+'em',
'ms-border-radius':r+'em',
'border-radius':r+'em',
'height':equalDim+'em',
'width':equalDim+'em',
'top':Math.random()*600+'px',
'left':Math.random()*1400+'px'
});
}
function splashVanish(droplet) {
droplet.fadeOut(Math.random()*6000, function(){
droplet.css({'top':Math.random()*600+'px','left':Math.random()*1400+'px'});
droplet.remove();
$("body").append(droplet);
droplet.fadeIn(1,function(){splashVanish(droplet)});
});
}