From d0bb8fcd2616fbfce4f55223875a323e14bad5bd Mon Sep 17 00:00:00 2001 From: Josh Kaplan Date: Fri, 19 Aug 2022 15:23:51 -0700 Subject: [PATCH] Prevent from steadily zooming in when cycling between alternate aspectRatios and original Issue below related - https://github.com/TimOliver/TOCropViewController/issues/354 --- Objective-C/TOCropViewController/Views/TOCropView.m | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Objective-C/TOCropViewController/Views/TOCropView.m b/Objective-C/TOCropViewController/Views/TOCropView.m index adf68d9e..65aca615 100755 --- a/Objective-C/TOCropViewController/Views/TOCropView.m +++ b/Objective-C/TOCropViewController/Views/TOCropView.m @@ -1403,9 +1403,12 @@ - (void)setAspectRatio:(CGSize)aspectRatio animated:(BOOL)animated return; } + BOOL zoomOut = NO; + // Passing in an empty size will revert back to the image aspect ratio if (aspectRatio.width < FLT_EPSILON && aspectRatio.height < FLT_EPSILON) { aspectRatio = (CGSize){self.imageSize.width, self.imageSize.height}; + zoomOut = YES; // Prevent from steadily zooming in when cycling between alternate aspectRatios and original } CGRect boundsFrame = self.contentBounds; @@ -1418,7 +1421,6 @@ - (void)setAspectRatio:(CGSize)aspectRatio animated:(BOOL)animated else cropBoxIsPortrait = aspectRatio.width < aspectRatio.height; - BOOL zoomOut = NO; if (cropBoxIsPortrait) { CGFloat newWidth = floorf(cropBoxFrame.size.height * (aspectRatio.width/aspectRatio.height)); CGFloat delta = cropBoxFrame.size.width - newWidth;