From bd3bf548c27f6be204cf89d98944b76ccdd01078 Mon Sep 17 00:00:00 2001
From: Fuwn <contact@fuwn.me>
Date: Thu, 18 Apr 2024 19:17:05 -0700
Subject: feat(badges): limit rotation

---
 src/lib/BadgeWall/BadgePreview.svelte | 3 +++
 1 file changed, 3 insertions(+)

(limited to 'src/lib/BadgeWall/BadgePreview.svelte')

diff --git a/src/lib/BadgeWall/BadgePreview.svelte b/src/lib/BadgeWall/BadgePreview.svelte
index 689ae927..dd2b7fd9 100644
--- a/src/lib/BadgeWall/BadgePreview.svelte
+++ b/src/lib/BadgeWall/BadgePreview.svelte
@@ -20,6 +20,7 @@
 	const handleMouseMove = (event: MouseEvent) => {
 		const boundingRectangle = badgeReference.getBoundingClientRect();
 		const factor = 1.25;
+		const limit = 300 * 1.75;
 
 		if ($mouse.x === 0 && $mouse.y === 0) $mouse = { x: event.clientX, y: event.clientY };
 
@@ -27,6 +28,8 @@
 			(-(event.clientX - boundingRectangle.left - boundingRectangle.width / 2) - $mouse.x) * factor;
 		$mouse.y +=
 			(-(event.clientY - boundingRectangle.top - boundingRectangle.height / 2) - $mouse.y) * factor;
+		$mouse.x = Math.max(Math.min($mouse.x, limit), -limit);
+		$mouse.y = Math.max(Math.min($mouse.y, limit), -limit);
 	};
 
 	const handleMouseLeave = () => {
-- 
cgit v1.2.3

