From 0dc7e655a20ed4714abe7e9fa19f3948029ed961 Mon Sep 17 00:00:00 2001 From: Jared Stoffan Date: Fri, 6 Nov 2020 14:15:04 -0800 Subject: [PATCH] fix(zoom): Round scale before comparing against max and min values (#1290) Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> --- .../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({