diff options
author | adam <adam@> | 2021-01-28 19:05:24 +0200 |
---|---|---|
committer | adam <adam@> | 2021-01-28 19:05:24 +0200 |
commit | 758afd5feefbf3a76f5c6abe8bff8c08f39dd7cc (patch) | |
tree | e0445832d241788e37e9795be2857d0854a0b268 /js | |
parent | 9cab0d0ed64f4e5289a0c979cae10a92508c391b (diff) | |
download | fileup-758afd5feefbf3a76f5c6abe8bff8c08f39dd7cc.tar.gz |
restructuring stuff
Diffstat (limited to 'js')
-rw-r--r-- | js/arrows.js | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/js/arrows.js b/js/arrows.js new file mode 100644 index 0000000..a23af87 --- /dev/null +++ b/js/arrows.js @@ -0,0 +1,37 @@ + +arrows = []; + +const minSpeed = 3; +const maxSpeed = 8; +const delay = 1500; +const lifetime = 25000; + +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.remove(ob); + }, 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(); |