feat(common): use delta time for the button selector animation
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user