Skip to content
Open
Changes from all commits
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
12 changes: 10 additions & 2 deletions Sources/Mantis/CropView/CropView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ final class CropView: UIView {
var forceFixedRatio = false
var checkForForceFixedRatioFlag = false
let cropViewConfig: CropViewConfig
private var debounceWorkItem: DispatchWorkItem?

private var flipOddTimes = false

Expand Down Expand Up @@ -879,9 +880,16 @@ extension CropView: CropViewProtocol {

let contentRect = getContentBounds()

adjustUIForNewCrop(contentRect: contentRect) { [weak self] in
self?.viewModel.setBetweenOperationStatus()
debounceWorkItem?.cancel()

let workItem = DispatchWorkItem { [weak self] in
self?.adjustUIForNewCrop(contentRect: contentRect) { [weak self] in
self?.viewModel.setBetweenOperationStatus()
}
}

debounceWorkItem = workItem
DispatchQueue.main.asyncAfter(deadline: .now() + 0.2, execute: workItem)
Comment on lines +883 to +892
Copy link

Copilot AI Oct 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] The debounce delay of 0.2 seconds is a magic number. Consider extracting it to a named constant (e.g., private let debounceDelay: TimeInterval = 0.2) at the class level to improve maintainability and make it easier to adjust if needed.

Copilot uses AI. Check for mistakes.
}
}

Expand Down