diff options
author | Quentin Dufour <quentin@deuxfleurs.fr> | 2023-10-17 09:51:32 +0200 |
---|---|---|
committer | Quentin Dufour <quentin@deuxfleurs.fr> | 2023-10-17 09:51:32 +0200 |
commit | a8a5a40027299e778ecec9a382efef4cd1af5633 (patch) | |
tree | 36b2571e9f36aa1d4e672fe93ee3b08b2b1f8cca /script-bon.js | |
parent | 91d10a7eb34c41d4a04e395f0e587142ea436da0 (diff) | |
download | site-a8a5a40027299e778ecec9a382efef4cd1af5633.tar.gz site-a8a5a40027299e778ecec9a382efef4cd1af5633.zip |
ajout du nouveau site dans le dépot
Diffstat (limited to 'script-bon.js')
-rw-r--r-- | script-bon.js | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/script-bon.js b/script-bon.js new file mode 100644 index 0000000..5458968 --- /dev/null +++ b/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 |