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..37de454e 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,21 @@ 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.floor( + Math.max( + Math.min(((startToEnd - currentToEnd) / startToEnd) * 100, 100), + 0, + ), + ); }; const ChairProgress: FC<{