From ca2935bedb3e4171ef62f47912ab14621945f411 Mon Sep 17 00:00:00 2001 From: Hiroshi Kimura Date: Fri, 29 Mar 2024 21:37:07 +0900 Subject: [PATCH] Disable Animation in CropView (#232) --- Sources/BrightroomUI/Shared/Components/Crop/CropView.swift | 6 ++++-- .../Shared/Components/Drawing/BlurryMaskingView.swift | 3 ++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/Sources/BrightroomUI/Shared/Components/Crop/CropView.swift b/Sources/BrightroomUI/Shared/Components/Crop/CropView.swift index 22e1fa34..23c4cb04 100644 --- a/Sources/BrightroomUI/Shared/Components/Crop/CropView.swift +++ b/Sources/BrightroomUI/Shared/Components/Crop/CropView.swift @@ -97,6 +97,8 @@ public final class CropView: UIView, UIScrollViewDelegate { } } + public var areAnimationsEnabled: Bool = true + public var isImageViewHidden: Bool { get { imagePlatterView.imageView.isHidden @@ -332,7 +334,7 @@ public final class CropView: UIView, UIScrollViewDelegate { editingStack.start() binding: do { - store.sinkState(queue: .mainIsolated()) { [weak self] state in + store.sinkState(queue: .mainIsolated()) { [weak self, areAnimationsEnabled] state in guard let self = self else { return } @@ -379,7 +381,7 @@ public final class CropView: UIView, UIScrollViewDelegate { self.updateScrollContainerView( by: crop, preferredAspectRatio: state.preferredAspectRatio, - animated: state.previous?.proposedCrop != nil /* whether first time load */, + animated: areAnimationsEnabled && state.previous?.proposedCrop != nil /* whether first time load */, animatesRotation: state.hasChanges(\.proposedCrop?.rotation) ) diff --git a/Sources/BrightroomUI/Shared/Components/Drawing/BlurryMaskingView.swift b/Sources/BrightroomUI/Shared/Components/Drawing/BlurryMaskingView.swift index 1598be7a..4a3fb2c3 100644 --- a/Sources/BrightroomUI/Shared/Components/Drawing/BlurryMaskingView.swift +++ b/Sources/BrightroomUI/Shared/Components/Drawing/BlurryMaskingView.swift @@ -83,7 +83,7 @@ public final class BlurryMaskingView: PixelEditorCodeBasedView, UIScrollViewDele } } - let backingView: CropView + private let backingView: CropView private let containerView = ContainerView() @@ -115,6 +115,7 @@ public final class BlurryMaskingView: PixelEditorCodeBasedView, UIScrollViewDele editingStack: editingStack, contentInset: .zero ) + self.backingView.areAnimationsEnabled = false self.backingView.accessibilityIdentifier = "BlurryMasking" store = .init(