aboutsummaryrefslogtreecommitdiff
path: root/static/script-bon.js
diff options
context:
space:
mode:
authorQuentin Dufour <quentin@deuxfleurs.fr>2023-10-17 10:05:18 +0200
committerQuentin Dufour <quentin@deuxfleurs.fr>2023-10-17 10:05:18 +0200
commit7dcd436b8407810c28933d7cfee8f6e36456d622 (patch)
tree51e8e581635de3141602b746a02afe66a89a2b52 /static/script-bon.js
parent4cbd53b6271f3ee616fc383bd03471e370b5a872 (diff)
downloadsite-7dcd436b8407810c28933d7cfee8f6e36456d622.tar.gz
site-7dcd436b8407810c28933d7cfee8f6e36456d622.zip
move root to static/ folder
Diffstat (limited to 'static/script-bon.js')
-rw-r--r--static/script-bon.js44
1 files changed, 44 insertions, 0 deletions
diff --git a/static/script-bon.js b/static/script-bon.js
new file mode 100644
index 0000000..5458968
--- /dev/null
+++ b/static/script-bon.js
@@ -0,0 +1,44 @@
+// dictionary to keep track of frame count for each animation
+let frameCounts = {};
+
+function animate(id, delay) {
+
+ // get the container and frames for the amination
+ const container = document.getElementById(id);
+ const frames = container.children;
+
+ // set up the frame counter
+ frameCounts[id] = 0;
+
+ // hide all frames except for the first
+ frames[0].style.display = "flex";
+ for (let i = 1; i < frames.length; i++) {
+ frames[i].style.display = "none";
+ }
+
+ // start the animation
+ const interval = setInterval(updateAnimation, delay, id, frames, frames.length);
+
+}
+
+function updateAnimation(id, frames, totalFrames) {
+
+ // increment the frame counter for the given id
+ frameCounts[id] = (frameCounts[id] + 1) % totalFrames;
+
+ // show the next frame
+ frames[frameCounts[id]].style.display = "flex";
+
+ // hide the previous frame
+ if (frameCounts[id] == 0) {
+ frames[totalFrames - 1].style.display = "none";
+ } else {
+ frames[frameCounts[id] - 1].style.display = "none";
+ }
+
+}
+
+animate("illustration-accueil", 500);
+animate("rennes", 1000);
+animate("orsay", 2000);
+animate("parterre", 1500); \ No newline at end of file