-
-
Notifications
You must be signed in to change notification settings - Fork 230
fix: mitigate the UI jumping issue when resizing the window on iPad #483
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR addresses a UI jumping issue on iPad during window resizing by implementing a debounce mechanism. The fix prevents rapid, successive UI adjustments that can cause visual flickering when the window dimensions change.
Key Changes:
- Added debounce logic to delay UI adjustments during window resize events
- Introduced a 200ms delay before processing resize-triggered UI updates
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| 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) |
Copilot
AI
Oct 22, 2025
There was a problem hiding this comment.
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.
|
Note Other AI code review bot(s) detectedCodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review. WalkthroughCropView now debounces UI updates by introducing a private DispatchWorkItem that schedules adjustUIForNewCrop completion handling on a 0.2-second delay, replacing immediate execution with batched asynchronous updates while preserving final effects. Changes
Sequence DiagramsequenceDiagram
participant User
participant CropView
participant DispatchQueue
participant UISystem
rect rgb(220, 240, 255)
Note over User,UISystem: Before: Immediate Execution
User->>CropView: Trigger crop adjustment
CropView->>CropView: adjustUIForNewCrop()
CropView->>UISystem: Update UI
CropView->>CropView: setBetweenOperationStatus()
end
rect rgb(220, 255, 220)
Note over User,UISystem: After: Debounced Execution
User->>CropView: Trigger crop adjustment (1st)
CropView->>DispatchQueue: Schedule work item (0.2s delay)
User->>CropView: Trigger crop adjustment (2nd)
CropView->>DispatchQueue: Cancel previous, reschedule (0.2s delay)
DispatchQueue->>CropView: Execute after 0.2s
CropView->>CropView: adjustUIForNewCrop()
CropView->>UISystem: Update UI (batched)
CropView->>CropView: setBetweenOperationStatus()
end
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes The change is concentrated in a single file with a clear, consistent pattern of debounce logic applied identically to two locations. The implementation is straightforward—adding a private property and replacing two completion handlers with delayed dispatch calls—requiring minimal context and focused verification of timing behavior. Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
🧰 Additional context used🧬 Code graph analysis (1)Sources/Mantis/CropView/CropView.swift (1)
🔇 Additional comments (2)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Summary by CodeRabbit