From a3548b880b1b88cd1fdad163e44afe6936fd56da Mon Sep 17 00:00:00 2001 From: Masanari Hamada Date: Sun, 8 Dec 2024 01:00:23 +0900 Subject: [PATCH 1/2] =?UTF-8?q?fix:=20current=E3=81=8C=E7=9B=B4=E7=B7=9A?= =?UTF-8?q?=E8=B7=9D=E9=9B=A2=E3=81=8B=E3=82=89=E5=A4=96=E3=82=8C=E3=81=9F?= =?UTF-8?q?=E3=82=8A=E3=80=81=E7=9B=AE=E7=9A=84=E5=9C=B0=E3=81=A8=E7=8F=BE?= =?UTF-8?q?=E5=9C=A8=E5=9C=B0=E3=81=8C=E5=90=8C=E3=81=98=E5=A0=B4=E5=90=88?= =?UTF-8?q?=E3=81=AB=E7=95=B0=E5=B8=B8=E5=80=A4=E3=81=AB=E3=81=AA=E3=82=8B?= =?UTF-8?q?=E3=81=AE=E3=82=92=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../simulator-configs/simulator-chair-config.tsx | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/frontend/app/components/modules/simulator-configs/simulator-chair-config.tsx b/frontend/app/components/modules/simulator-configs/simulator-chair-config.tsx index 7a585c27..bc390c75 100644 --- a/frontend/app/components/modules/simulator-configs/simulator-chair-config.tsx +++ b/frontend/app/components/modules/simulator-configs/simulator-chair-config.tsx @@ -17,13 +17,19 @@ const progress = ( current: Coordinate, end: Coordinate, ): number => { - const distance = + const startToEnd = Math.abs(end.latitude - start.latitude) + Math.abs(end.longitude - start.longitude); - const progress = + if (startToEnd === 0) { + return 100; + } + const currentToEnd = Math.abs(end.latitude - current.latitude) + Math.abs(end.longitude - current.longitude); - return Math.floor(((distance - progress) / distance) * 100); + return Math.max( + Math.min(((startToEnd - currentToEnd) / startToEnd) * 100, 100), + 0, + ); }; const ChairProgress: FC<{ From be9547321a1860d47956c52be0ba5c6c87a5c416 Mon Sep 17 00:00:00 2001 From: Masanari Hamada Date: Sun, 8 Dec 2024 01:18:38 +0900 Subject: [PATCH 2/2] =?UTF-8?q?fix:=20floor=E3=82=92=E6=88=BB=E3=81=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../modules/simulator-configs/simulator-chair-config.tsx | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/frontend/app/components/modules/simulator-configs/simulator-chair-config.tsx b/frontend/app/components/modules/simulator-configs/simulator-chair-config.tsx index bc390c75..37de454e 100644 --- a/frontend/app/components/modules/simulator-configs/simulator-chair-config.tsx +++ b/frontend/app/components/modules/simulator-configs/simulator-chair-config.tsx @@ -26,9 +26,11 @@ const progress = ( const currentToEnd = Math.abs(end.latitude - current.latitude) + Math.abs(end.longitude - current.longitude); - return Math.max( - Math.min(((startToEnd - currentToEnd) / startToEnd) * 100, 100), - 0, + return Math.floor( + Math.max( + Math.min(((startToEnd - currentToEnd) / startToEnd) * 100, 100), + 0, + ), ); };