From 29b6fec55cfe2d7c5bb59324d0cfb75bd7426c7a Mon Sep 17 00:00:00 2001 From: Yingtao Guo Date: Fri, 26 Apr 2024 21:10:28 +0800 Subject: [PATCH] fix: fix undo redo rotation issues when flipped (#396) --- Sources/Mantis/CropView/CropView.swift | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/Sources/Mantis/CropView/CropView.swift b/Sources/Mantis/CropView/CropView.swift index 6fceb4bd..16623a97 100644 --- a/Sources/Mantis/CropView/CropView.swift +++ b/Sources/Mantis/CropView/CropView.swift @@ -978,12 +978,10 @@ extension CropView: CropViewProtocol { var newTransform = getTransformInfo(byTransformInfo: cropState.transformation) - if viewModel.horizontallyFlip { - newTransform.rotation = -newTransform.rotation - } - - if viewModel.verticallyFlip { - newTransform.rotation = -newTransform.rotation + if flipOddTimes { + let localRotation = newTransform.rotation.truncatingRemainder(dividingBy: .pi/2) + let rotation90s = newTransform.rotation - localRotation + newTransform.rotation = -rotation90s + localRotation } if newTransform.maskFrame != .zero {