From 88a881baec84135df5d2670858fbf121cdd7fc33 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=A0imon=20Brandner?= Date: Sat, 3 Apr 2021 16:19:22 +0200 Subject: [PATCH] ZOOM_DISTANCE into a const MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Šimon Brandner --- src/components/views/elements/ImageView.tsx | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/components/views/elements/ImageView.tsx b/src/components/views/elements/ImageView.tsx index e54e519707..e58601f142 100644 --- a/src/components/views/elements/ImageView.tsx +++ b/src/components/views/elements/ImageView.tsx @@ -38,6 +38,9 @@ const MAX_ZOOM = 300; const ZOOM_STEP = 10; // This is used for mouse wheel events const ZOOM_COEFFICIENT = 10; +// If we have moved only this much we can zoom +const ZOOM_DISTANCE = 10; + interface IProps { src: string, // the source of the image being displayed @@ -234,8 +237,8 @@ export default class ImageView extends React.Component { // Zoom out if we haven't moved much if ( this.state.moving === true && - Math.abs(this.state.translationX - this.previousX) < 10 && - Math.abs(this.state.translationY - this.previousY) < 10 + Math.abs(this.state.translationX - this.previousX) < ZOOM_DISTANCE && + Math.abs(this.state.translationY - this.previousY) < ZOOM_DISTANCE ) { this.setState({ zoom: MIN_ZOOM,