@@ -318,14 +318,17 @@ public class ConfirmViewController: UIViewController, UIScrollViewDelegate {
318318 y: cropOverlay. frame. origin. y + cropOverlay. outterGap,
319319 width: cropOverlay. frame. size. width - 2 * cropOverlay. outterGap,
320320 height: cropOverlay. frame. size. height - 2 * cropOverlay. outterGap)
321- cropRect. origin. x += scrollView. contentOffset. x
322- cropRect. origin. y += scrollView. contentOffset. y
323-
324- let normalizedX = cropRect. origin. x / imageView. frame. width
325- let normalizedY = cropRect. origin. y / imageView. frame. height
326-
327- let normalizedWidth = cropRect. width / imageView. frame. width
328- let normalizedHeight = cropRect. height / imageView. frame. height
321+ cropRect. origin. x += scrollView. contentOffset. x - imageView. frame. origin. x
322+ cropRect. origin. y += scrollView. contentOffset. y - imageView. frame. origin. y
323+
324+ let normalizedX = max ( 0 , cropRect. origin. x / imageView. frame. width)
325+ let normalizedY = max ( 0 , cropRect. origin. y / imageView. frame. height)
326+
327+ let extraWidth = min ( 0 , cropRect. origin. x)
328+ let extraHeight = min ( 0 , cropRect. origin. y)
329+
330+ let normalizedWidth = min ( 1 , ( cropRect. width + extraWidth) / imageView. frame. width)
331+ let normalizedHeight = min ( 1 , ( cropRect. height + extraHeight) / imageView. frame. height)
329332
330333 return CGRect ( x: normalizedX, y: normalizedY, width: normalizedWidth, height: normalizedHeight)
331334 }
0 commit comments