From 2ad632377a099824990e15303c5caf736f73bf91 Mon Sep 17 00:00:00 2001 From: Yingtao Guo Date: Thu, 25 Apr 2024 21:21:44 +0800 Subject: [PATCH] fix: fix the rotation issue when undo/redo for a flipped image (#393) (#394) --- Sources/Mantis/CropView/CropView.swift | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/Sources/Mantis/CropView/CropView.swift b/Sources/Mantis/CropView/CropView.swift index 6ee928c0..6fceb4bd 100644 --- a/Sources/Mantis/CropView/CropView.swift +++ b/Sources/Mantis/CropView/CropView.swift @@ -976,7 +976,15 @@ extension CropView: CropViewProtocol { viewModel.fixedImageRatio = cropState.aspectRato flipOddTimes = cropState.flipOddTimes - let newTransform = getTransformInfo(byTransformInfo: cropState.transformation) + var newTransform = getTransformInfo(byTransformInfo: cropState.transformation) + + if viewModel.horizontallyFlip { + newTransform.rotation = -newTransform.rotation + } + + if viewModel.verticallyFlip { + newTransform.rotation = -newTransform.rotation + } if newTransform.maskFrame != .zero { viewModel.cropBoxFrame = newTransform.maskFrame