Repository navigation
fix(ios): frame camera commands against the final edge insets - #102
Merged
Merged
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This branch was successfully deployed
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.
Summary
On iOS, a
moveCameraorfitCoordinatessent while an animatedsetEdgeInsetsis still running frames against the wrong insets. Callers that animate the insets with a sheet and then refit have to wait out the animation (300 ms by default) before fitting._mapView.paddingframe by frame.fitBoundsresolves against the padding at the moment it's called, so it uses the in-between value.setCenterCoordinate:animated:NO, which cancels a running camera animation. The fit stops on the first frame, and the map only shifts with the insets.The fix:
fitCoordinatescomputes the camera withcameraForBounds:insets:with the padding set to the target insets for the call. The padding animation keeps running, and the camera target stays centered in the padding while it does.moveCameraalready used a camera target, so it's unchanged.moveCameraandfitCoordinatesfirst finish a running inset animation by setting the finallayoutMarginswithout the re-center. The camera command moves the map anyway.Android already applies the final padding before a camera update (see #101).
Type of Change
Test Plan
Bare example on the iOS 27 simulator (iPhone 18 Pro Max). "Fit Markers" and "Move Camera" were temporarily changed to call
setEdgeInsets(bottom +300, default animation) right before the camera command. A second plain "Fit Markers" gives the correct frame. The status line gives the camera center and zoom.37.78423, -122.42650 (z13.9). The plain fit moves to(z13.4).37.78456, -122.42650 (z13.4). The plain fit doesn't move the camera.37.78000, -122.43000 (z13.9): the center doesn't move and a marker ends at the top edge. The plain fit moves to37.78456, -122.42650 (z13.4).37.78456, -122.42650 (z13.4). The plain fit doesn't move the camera.37.77500, -122.4430037.77500, -122.44300Screenshots / Videos
Checklist