From 4c815d912920aada6dd1b08277c9b133684fb36a Mon Sep 17 00:00:00 2001
From: Icetang0123 <1415wwwh@gmail.com>
Date: Fri, 13 Feb 2026 19:40:37 +0900
Subject: [PATCH] Enhance button movement logic and distance threshold
Added logic to ensure button movement when position rounding occurs and adjusted distance threshold for button movement.
---
index.html | 21 +++++++++++++++++----
1 file changed, 17 insertions(+), 4 deletions(-)
diff --git a/index.html b/index.html
index 2c485f91a..0ee17fbcb 100644
--- a/index.html
+++ b/index.html
@@ -271,6 +271,20 @@
YAY! 🎉
newLeft = clamp(newLeft, 0, z.width - b.width);
newTop = clamp(newTop, 0, z.height - b.height);
+ // If the integer part of the new position is the same as the current, it means the button didn't move (probably due to rounding), so we force it to move in that case
+
+ if (Math.floor(newLeft) === Math.floor(b.left - z.left) &&
+ Math.floor(newTop) === Math.floor(b.top - z.top)) {
+ // Overflow - add half the available space to ensure movement even from (0,0)
+ const maxLeft = z.width - b.width;
+ const maxTop = z.height - b.height;
+
+ newLeft = (newLeft + maxLeft / 2) % maxLeft;
+ newTop = (newTop + maxTop / 2) % maxTop;
+ newLeft = clamp(newLeft, 0, maxLeft);
+ newTop = clamp(newTop, 0, maxTop);
+ }
+
noBtn.style.left = newLeft + "px";
noBtn.style.top = newTop + "px";
noBtn.style.transform = "none";
@@ -284,7 +298,8 @@ YAY! 🎉
(b.left + b.width / 2) - e.clientX,
(b.top + b.height / 2) - e.clientY
);
- if (d < 140) moveNo(e.clientX, e.clientY);
+
+ if (d < 100) moveNo(e.clientX, e.clientY);
});
noBtn.addEventListener("click", e => e.preventDefault());
@@ -294,12 +309,10 @@ YAY! 🎉
zone.style.display = "none";
hint.style.display = "none"; // HIDE THE HINT
result.style.display = "block";
+
resizeConfettiCanvas();
fullScreenConfetti();
});