From 0023234c3c03ce6197c6525548d15bdad43b3e7c Mon Sep 17 00:00:00 2001 From: Pihkaal Date: Wed, 7 Jan 2026 11:14:44 +0100 Subject: [PATCH] feat(common): use delta time for the button selector animation --- app/components/Common/ButtonSelector.vue | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/app/components/Common/ButtonSelector.vue b/app/components/Common/ButtonSelector.vue index 8a14fad..9fa0f92 100644 --- a/app/components/Common/ButtonSelector.vue +++ b/app/components/Common/ButtonSelector.vue @@ -14,12 +14,12 @@ const { onRender } = useScreen(); const app = useAppStore(); const { assets } = useAssets(); -const ANIMATION_SPEED = 0.25; +const ANIMATION_SPEED = 15; const CORNER_SIZE = 11; let [currentX, currentY, currentWidth, currentHeight] = props.rect; -onRender((ctx) => { +onRender((ctx, deltaTime) => { const [targetX, targetY, targetWidth, targetHeight] = props.rect; const dx = targetX - currentX; const dy = targetY - currentY; @@ -34,10 +34,11 @@ onRender((ctx) => { ) { [currentX, currentY, currentWidth, currentHeight] = props.rect; } else { - currentX += dx * ANIMATION_SPEED; - currentY += dy * ANIMATION_SPEED; - currentWidth += dw * ANIMATION_SPEED; - currentHeight += dh * ANIMATION_SPEED; + const speed = (ANIMATION_SPEED * deltaTime) / 1000; + currentX += dx * speed; + currentY += dy * speed; + currentWidth += dw * speed; + currentHeight += dh * speed; } const x = Math.floor(currentX);