From 440865f91a6b6508280659fd554aa230e4544ce2 Mon Sep 17 00:00:00 2001 From: bingus_violet Date: Sat, 20 Apr 2024 12:24:46 -0500 Subject: [PATCH] Spin counter more consistent --- static/main.js | 25 +++++++++++++------------ static/root.css | 1 + 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/static/main.js b/static/main.js index 33be5a7..496d7f6 100644 --- a/static/main.js +++ b/static/main.js @@ -4,19 +4,18 @@ catsOnMars.loop = true var spins = 1 -function notif(text) { - document.body.innerHTML = "apple" -} - -function secondLoop() { - var pfp = document.querySelector(".pfp") - if (!catsOnMars.paused) { - spins += 0.5 - document.querySelector(".spinnyCount").innerHTML = `You have spun Violet ${Math.floor(spins)} times!` + pfp.style.animationDuration - } +var spinWaiting = false +function spinLoop() { + spinWaiting = true setTimeout(() => { - secondLoop() + spinWaiting = false + var pfp = document.querySelector(".pfp") + if (!catsOnMars.paused) { + spins += 0.5 + document.querySelector(".spinnyCount").innerHTML = `Violet has spun ${Math.floor(spins)} times!` + pfp.style.animationDuration + spinLoop() + } }, 1000); } @@ -26,11 +25,13 @@ window.onbeforeunload = function () { window.onload = function () { window.scrollTo(0, 0); - secondLoop() var pfp = document.querySelector(".pfp") pfp.addEventListener("mousedown", () => { + if (!spinWaiting) { + spinLoop(); + } catsOnMars.play() pfp.style.animationName = "spinny" diff --git a/static/root.css b/static/root.css index 4ec9ba5..bebb8dd 100644 --- a/static/root.css +++ b/static/root.css @@ -54,6 +54,7 @@ transform: scale(0.9); border-radius: 50%; rotate: 0deg; + user-select: none; animation-duration: 2s; animation-timing-function: linear;