diff options
author | alexvitkov <44268717+alexvitkov@users.noreply.github.com> | 2021-01-29 12:52:06 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-01-29 12:52:06 +0200 |
commit | 33e533d28dbf9ad7bfc7ad9af467e5efe25ae8a0 (patch) | |
tree | 7b748d2b87ab018d7ff451b4111a1b88eeb58416 /js/arrows.js | |
parent | ceedd596c9f39f53555fd0746a42d6b85cd49b6c (diff) | |
parent | 472e170f408e3d8d1db2eb066d445153aad55d73 (diff) | |
download | fileup-33e533d28dbf9ad7bfc7ad9af467e5efe25ae8a0.tar.gz |
Merge pull request #1 from GTSimeonov/master
rararrararararraar
Diffstat (limited to 'js/arrows.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..10ad416 --- /dev/null +++ b/js/arrows.js @@ -0,0 +1,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(); |