Fix CropView auto-commit during held-still pinch#307
Merged
Conversation
In Crop mode, holding a pinch still (fingers down, no movement) would snap the scroll view back to the recorded crop after ~0.8s, looking like the crop was committed mid-gesture. The `onDidZoom` trailing debounce ran `updateCropLayout()` — whose `customZoom(to:)` resets the scroll view to the not-yet-recorded `proposedCrop`. While moving, continuous `scrollViewDidZoom` events kept resetting the 0.8s debounce; once the user held still, events stopped and the debounce fired mid-pinch. The sibling `onDidScroll` debounce already guarded against this with an `isTracking == false` check, but `onDidZoom` had no equivalent guard (and both share the same debounce). Guard the `onDidZoom` settle layout with `cropSurface.isInteractiveZoomGestureActive == false` so the reflow is deferred until the pinch actually ends. The crop recording path (`record()` via the settle debounce) already checks `isContentOffsetResting`, so commit semantics are unchanged. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
In Crop mode, holding a pinch still (fingers down, no movement) would snap the scroll view back to the recorded crop after ~0.8s, making it look like the crop was committed mid-gesture.
Cause
cropSurface.onDidZoomschedulesupdateCropLayout()on a trailingdebounce(interval 0.8s).updateCropLayout()→updateScrollContainerView()→customZoom(to: crop.zoomExtent())resets the scroll view tostate.proposedCrop, which is not updated mid-pinch (record()only runs on settle).While the user moves their fingers, continuous
scrollViewDidZoomevents keep resetting the 0.8s debounce. The moment the user holds still with fingers down, events stop firing and the debounce fires mid-gesture, snapping the view.The sibling
onDidScrolldebounce already guards against this for drags with anisTracking == falsecheck, butonDidZoomhad no equivalent guard — and both closures share the samedebounceinstance, so whether the snap happens depends on which event was scheduled last.Fix
Guard the
onDidZoomsettle layout withcropSurface.isInteractiveZoomGestureActive == false(pinch recognizer not in.began/.changed), deferring the reflow until the pinch actually ends.The crop recording path (
record()via thescrollViewSettleDebounce→didSettleScrollViewAdjustment) already checksisContentOffsetResting(isZooming == false, etc.), so commit semantics are unchanged — this only stops the premature layout snap.Verification
BrightroomUIbuilds (iPhone 17 Pro, iOS 26.5).🤖 Generated with Claude Code