aboutsummaryrefslogtreecommitdiffstats
path: root/arrows.js
diff options
context:
space:
mode:
authorAlex Vitkov <alexvitkov98@gmail.com>2020-12-03 21:10:17 +0200
committerAlex Vitkov <alexvitkov98@gmail.com>2020-12-03 21:10:17 +0200
commit6c745ea0f54e660577d070b2ddaf4977039a094a (patch)
treee3938f21c98f7f459bc2589989d9e7f4c25d2950 /arrows.js
downloadfileup-6c745ea0f54e660577d070b2ddaf4977039a094a.tar.gz
initial
Diffstat (limited to 'arrows.js')
-rw-r--r--arrows.js37
1 files changed, 37 insertions, 0 deletions
diff --git a/arrows.js b/arrows.js
new file mode 100644
index 0000000..4584aea
--- /dev/null
+++ b/arrows.js
@@ -0,0 +1,37 @@
+
+arrows = [];
+
+const minSpeed = 3;
+const maxSpeed = 8;
+const delay = 3000;
+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.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();