Skip to content

Commit e47dd62

Browse files
authored
Merge pull request #534 from yhkaplan/zoom-out-on-reset-aspect-ratio
Prevent from steadily zooming in when cycling between alternate aspectRatios and original
2 parents 9f0202a + d0bb8fc commit e47dd62

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

Objective-C/TOCropViewController/Views/TOCropView.m

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1403,9 +1403,12 @@ - (void)setAspectRatio:(CGSize)aspectRatio animated:(BOOL)animated
14031403
return;
14041404
}
14051405

1406+
BOOL zoomOut = NO;
1407+
14061408
// Passing in an empty size will revert back to the image aspect ratio
14071409
if (aspectRatio.width < FLT_EPSILON && aspectRatio.height < FLT_EPSILON) {
14081410
aspectRatio = (CGSize){self.imageSize.width, self.imageSize.height};
1411+
zoomOut = YES; // Prevent from steadily zooming in when cycling between alternate aspectRatios and original
14091412
}
14101413

14111414
CGRect boundsFrame = self.contentBounds;
@@ -1418,7 +1421,6 @@ - (void)setAspectRatio:(CGSize)aspectRatio animated:(BOOL)animated
14181421
else
14191422
cropBoxIsPortrait = aspectRatio.width < aspectRatio.height;
14201423

1421-
BOOL zoomOut = NO;
14221424
if (cropBoxIsPortrait) {
14231425
CGFloat newWidth = floorf(cropBoxFrame.size.height * (aspectRatio.width/aspectRatio.height));
14241426
CGFloat delta = cropBoxFrame.size.width - newWidth;

0 commit comments

Comments
 (0)