blob: 10ad416c986101a76b5174df55d239ea2c0f88f9 (
plain)
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
|
arrows = [];
const minSpeed = 3;
const maxSpeed = 8;
const delay = 1500;
const lifetime = 20000;
function make_arrow() {
const svg = document.getElementById("protoarrow").cloneNode();
svg.style.left = Math.random() * 100 + '%';
svg.style.display = 'block';
document.getElementById('arrows').append(svg);
const ob = {
y: -800,
svg: svg,
speed: Math.random() * (maxSpeed - minSpeed) + minSpeed
};
arrows.push(ob);
setTimeout(make_arrow, delay);
setTimeout(() => {
svg.remove();
arrows.shift();
}, lifetime);
}
function update() {
for (const arrow of arrows) {
arrow.y += arrow.speed;
arrow.svg.style.bottom = arrow.y + 'px';
}
window.requestAnimationFrame(update);
}
make_arrow();
update();
|