-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.js
47 lines (39 loc) · 1.27 KB
/
index.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
var dropCount = 500;
var w = window.innerWidth;
var h = window.innerHeight;
var iw = document.documentElement.clientWidth;
var ih = document.documentElement.clientHeight;
var bw = document.getElementsByTagName("body")[0].clientWidth;
var bh = document.getElementsByTagName("body")[0].clientHeight;
var block = document.getElementsByTagName("body")[0];
var rain = document.getElementById("raindrop");
var dot = document.getElementById("dot");
var initialTop = block.clientHeight * -1;
var width = w || iw || bw;
var height = h || ih || bh;
for(var i = 0; i < dropCount; ++i) {
var posY = Math.round(Math.random() * height);
var posX = Math.round(Math.random() * width);
var drops = document.createElement("div");
drops.innerHTML = rain.outerHTML;
var speed = 1000 * 30;
var speedDelay = 2000;
drops.setAttribute("class", "drops" + (3 - Math.floor(speed / 1000 / 8)));
block.appendChild(drops);
drops.animate (
[
{
transform: "translate3d(" + 0 + "vw, " + initialTop + "vh, 0)"
},
{
transform:
"translate3d(" + Math.random() * 256 + "vw, " + posY + "vh, 0)"
}
],
{
delay: Math.random() * -speed,
duration: speedDelay,
iterations: 1000
}
);
}