Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Example/DemoViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ class DemoViewController: UIViewController {
config.cropViewConfig.cropActivityIndicator = CustomWaitingIndicator(frame: indicatorFrame)
config.cropToolbarConfig.toolbarButtonOptions = [.clockwiseRotate, .reset, .ratio, .autoAdjust, .horizontallyFlip]

// config.cropViewConfig.rotateCropBoxFor90DegreeRotation = false
Comment thread
guoyingtao marked this conversation as resolved.
Outdated
if let transformation = transformation {
config.cropViewConfig.presetTransformationType = .presetInfo(info: transformation)
}
Expand Down
12 changes: 4 additions & 8 deletions Sources/Mantis/CropView/CropView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -340,12 +340,7 @@ final class CropView: UIView {

func updateCropBoxFrame(withTouchPoint touchPoint: CGPoint) {
let imageContainerRect = imageContainer.convert(imageContainer.bounds, to: self)
let imageFrame = CGRect(x: cropWorkbenchView.frame.origin.x - cropWorkbenchView.contentOffset.x,
y: cropWorkbenchView.frame.origin.y - cropWorkbenchView.contentOffset.y,
width: imageContainerRect.size.width,
height: imageContainerRect.size.height)

let touchPoint = confineTouchPoint(touchPoint, in: imageFrame)
let touchPoint = confineTouchPoint(touchPoint, in: imageContainerRect)
let contentBounds = getContentBounds()
let cropViewMinimumBoxSize = cropViewConfig.minimumCropBoxSize
let newCropBoxFrame = viewModel.getNewCropBoxFrame(withTouchPoint: touchPoint,
Expand Down Expand Up @@ -599,9 +594,9 @@ extension CropView {
isManuallyZoomed = true
}

func makeSureImageContainsCropOverlay() {
func makeSureImageContainsCropOverlay(animated: Bool = true) {
if !imageContainer.contains(rect: cropAuxiliaryIndicatorView.frame, fromView: self, tolerance: 0.25) {
cropWorkbenchView.zoomScaleToBound(animated: true)
cropWorkbenchView.zoomScaleToBound(animated: animated)
}
}

Expand Down Expand Up @@ -934,6 +929,7 @@ extension CropView: CropViewProtocol {
updatePositionFor90Rotation(by: rotateAngle + viewModel.radians)
} else {
adjustWorkbenchView(by: rotateAngle + viewModel.radians)
makeSureImageContainsCropOverlay(animated: false)
}
}

Expand Down