From 9ec9d606333b8bb9987a086bc649a3d412df9374 Mon Sep 17 00:00:00 2001 From: bboysoul Date: Fri, 11 Sep 2026 17:18:25 +0800 Subject: [PATCH] fix: align floating button safe bounds --- frontend/src/lib/mvp-utils.test.ts | 8 ++++---- frontend/src/lib/mvp-utils.ts | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/frontend/src/lib/mvp-utils.test.ts b/frontend/src/lib/mvp-utils.test.ts index f038283..77255fd 100644 --- a/frontend/src/lib/mvp-utils.test.ts +++ b/frontend/src/lib/mvp-utils.test.ts @@ -177,14 +177,14 @@ describe('MVP view utilities', () => { it('keeps the draggable mobile add button inside the viewport', () => { expect(clampFabPosition(-10, -20, 390, 844)).toEqual({ x: 14, y: 14 }) - expect(clampFabPosition(500, 900, 390, 844)).toEqual({ x: 324, y: 718 }) + expect(clampFabPosition(500, 900, 390, 844)).toEqual({ x: 320, y: 704 }) expect(clampFabPosition(120, 300, 390, 844)).toEqual({ x: 120, y: 300 }) }) it('snaps the add button to the nearest horizontal edge while preserving its safe vertical position', () => { - expect(snapFabPosition(40, 300, 390, 844)).toEqual({ x: 14, y: 300 }) - expect(snapFabPosition(280, 300, 390, 844)).toEqual({ x: 324, y: 300 }) - expect(snapFabPosition(180, 900, 390, 844)).toEqual({ x: 324, y: 718 }) + expect(snapFabPosition(40, 300, 390, 844, 56, 14, 84)).toEqual({ x: 14, y: 300 }) + expect(snapFabPosition(280, 300, 390, 844, 56, 14, 84)).toEqual({ x: 320, y: 300 }) + expect(snapFabPosition(180, 900, 390, 844, 56, 14, 84)).toEqual({ x: 320, y: 704 }) }) it('validates safe habit input and emits only changed patch fields', () => { diff --git a/frontend/src/lib/mvp-utils.ts b/frontend/src/lib/mvp-utils.ts index 225c179..3269486 100644 --- a/frontend/src/lib/mvp-utils.ts +++ b/frontend/src/lib/mvp-utils.ts @@ -163,14 +163,14 @@ export async function performTrashMutation( return { mutated: true, refreshed: await refresh() } } -export function clampFabPosition(x: number, y: number, viewportWidth: number, viewportHeight: number, size = 52, margin = 14, bottomReserved = 74) { +export function clampFabPosition(x: number, y: number, viewportWidth: number, viewportHeight: number, size = 56, margin = 14, bottomReserved = 84) { return { x: Math.min(Math.max(x, margin), Math.max(margin, viewportWidth - size - margin)), y: Math.min(Math.max(y, margin), Math.max(margin, viewportHeight - size - bottomReserved)), } } -export function snapFabPosition(x: number, y: number, viewportWidth: number, viewportHeight: number, size = 52, margin = 14, bottomReserved = 74) { +export function snapFabPosition(x: number, y: number, viewportWidth: number, viewportHeight: number, size = 56, margin = 14, bottomReserved = 84) { const clamped = clampFabPosition(x, y, viewportWidth, viewportHeight, size, margin, bottomReserved) const left = margin const right = Math.max(margin, viewportWidth - size - margin)