From fff8927d600ace883041f98917f2d346175535cb Mon Sep 17 00:00:00 2001 From: Jared Stoffan Date: Fri, 6 Nov 2020 11:36:40 -0800 Subject: [PATCH] fix(zoom): Round scale before comparing against max and min values --- .../viewers/controls/zoom/ZoomControls.tsx | 8 +++--- .../zoom/__tests__/ZoomControls-test.tsx | 27 ++++++++++--------- 2 files changed, 18 insertions(+), 17 deletions(-) diff --git a/src/lib/viewers/controls/zoom/ZoomControls.tsx b/src/lib/viewers/controls/zoom/ZoomControls.tsx index 6cb61a7ba..fd2e2ddd2 100644 --- a/src/lib/viewers/controls/zoom/ZoomControls.tsx +++ b/src/lib/viewers/controls/zoom/ZoomControls.tsx @@ -22,7 +22,7 @@ export default function ZoomControls({ onZoomOut, scale = 1, }: Props): JSX.Element { - const currentZoom = Math.round(scale * 100); + const currentScale = Math.round((scale + Number.EPSILON) * 100) / 100; const maxScaleValue = isFinite(maxScale) ? Math.min(maxScale, MAX_SCALE) : MAX_SCALE; const minScaleValue = isFinite(minScale) ? Math.max(minScale, MIN_SCALE) : MIN_SCALE; @@ -31,7 +31,7 @@ export default function ZoomControls({