From ab9f5102391b1bdf3745e0c1a98a13e1f5d72bdd Mon Sep 17 00:00:00 2001 From: Santiago Date: Tue, 28 May 2024 20:35:15 -0500 Subject: [PATCH] fix(CropZoom): fixes 'crash' when cropping an element with an aspect ratio of one --- .../src/cropzoom/common-example/CropManagedExample.tsx | 9 +++++++-- example/src/resumable/ResumableZoomExample.tsx | 1 + src/commons/utils/getCropRotatedSize.ts | 6 +++--- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/example/src/cropzoom/common-example/CropManagedExample.tsx b/example/src/cropzoom/common-example/CropManagedExample.tsx index 94ff619..302df10 100644 --- a/example/src/cropzoom/common-example/CropManagedExample.tsx +++ b/example/src/cropzoom/common-example/CropManagedExample.tsx @@ -42,7 +42,11 @@ const CropManagedExample = ({}) => { resolution={resolution} OverlayComponent={renderOverlay} > - + {/* @@ -70,7 +74,8 @@ const styles = StyleSheet.create({ backgroundColor: '#121212', }, image: { - flex: 1, + width: '100%', + height: '100%', }, }); diff --git a/example/src/resumable/ResumableZoomExample.tsx b/example/src/resumable/ResumableZoomExample.tsx index e76baad..fcedcd0 100644 --- a/example/src/resumable/ResumableZoomExample.tsx +++ b/example/src/resumable/ResumableZoomExample.tsx @@ -71,6 +71,7 @@ const ResumableZoomExample: React.FC = ({}) => { ref={ref} hitSlop={{ vertical: 50 }} maxScale={resolution} + extendGestures={true} onTap={onTap} > ; angle: number; - aspectRatio?: number; + aspectRatio: number; }; export const getCropRotatedSize = (options: Options): SizeVector => { 'worklet'; - const { size, angle, aspectRatio = 1 } = options; + const { size, angle, aspectRatio } = options; const sinWidth = Math.abs(size.height * Math.sin(angle)); const cosWidth = Math.abs(size.width * Math.cos(angle)); @@ -23,6 +23,6 @@ export const getCropRotatedSize = (options: Options): SizeVector => { return getAspectRatioSize({ aspectRatio: aspectRatio, width: aspectRatio >= 1 ? undefined : maxWidth, - height: aspectRatio > 1 ? maxHeight : undefined, + height: aspectRatio >= 1 ? maxHeight : undefined, }); };