Skip to content

Commit

Permalink
[RSKImageCropper] Restore the previous behavior of `[RSKImageScrollVi…
Browse files Browse the repository at this point in the history
…ew zoomToRect:animated:]`.
  • Loading branch information
ruslanskorb committed Apr 8, 2024
1 parent 7a7d096 commit 079dcc9
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 16 deletions.
4 changes: 3 additions & 1 deletion RSKImageCropper/RSKImageCropViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -652,7 +652,9 @@ - (void)handleRotation:(UIRotationGestureRecognizer *)gestureRecognizer

- (void)zoomToRect:(CGRect)rect animated:(BOOL)animated
{
[self.imageScrollView zoomToRect:[self.imageScrollView convertRect:rect fromView:self.view] animated:animated];
rect = [self.imageScrollView convertRect:rect fromView:self.view];
rect = [self.imageScrollView convertRect:rect toCoordinateSpace:self.imageScrollView.imageCoordinateSpace];
[self.imageScrollView zoomToRect:rect animated:animated];
}

#pragma mark - Public
Expand Down
13 changes: 5 additions & 8 deletions RSKImageCropper/RSKImageScrollView.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,11 @@ NS_SWIFT_UI_ACTOR
*/
@property (nonatomic, nullable, strong) UIColor *imageBackgroundColor;

/**
The coordinate space of the image.
*/
@property (nonatomic, readonly) id<UICoordinateSpace> imageCoordinateSpace;

/**
The current frame of the image in the coordinate space of the image scroll view.
*/
Expand Down Expand Up @@ -107,14 +112,6 @@ NS_SWIFT_UI_ACTOR
*/
- (void)zoomToLocation:(CGPoint)location animated:(BOOL)animated;

/**
Zooms to a specific area of the image so that it’s visible in the image scroll view.
@param rect A rectangle defining an area of the image. The rectangle should be in the coordinate space of the image scroll view.
@param animated `YES` if the scrolling should be animated, `NO` if it should be immediate.
*/
- (void)zoomToRect:(CGRect)rect animated:(BOOL)animated;

@end

@interface RSKImageScrollView (Deprecated)
Expand Down
12 changes: 5 additions & 7 deletions RSKImageCropper/RSKImageScrollView.m
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,11 @@ - (void)setImageBackgroundColor:(UIColor *)imageBackgroundColor
_imageView.backgroundColor = imageBackgroundColor;
}

- (id<UICoordinateSpace>)imageCoordinateSpace
{
return [_imageView coordinateSpace];
}

- (CGRect)imageFrame
{
return _imageView.frame;
Expand Down Expand Up @@ -204,13 +209,6 @@ - (void)zoomToLocation:(CGPoint)location animated:(BOOL)animated
[self zoomToRect:rect animated:animated];
}

- (void)zoomToRect:(CGRect)rect animated:(BOOL)animated
{
rect = [_imageView convertRect:rect fromView:self];

[super zoomToRect:rect animated:animated];
}

#pragma mark - UIScrollViewDelegate

- (UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView
Expand Down

0 comments on commit 079dcc9

Please sign in to comment.