-
Notifications
You must be signed in to change notification settings - Fork 150
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
Rotation gesture threshold and simultaneousRotateAndPinchToZoomEnabled option #1429
Conversation
63d90ef
to
1b3170d
Compare
Sources/MapboxMaps/Gestures/GestureHandlers/RotateGestureHandler.swift
Outdated
Show resolved
Hide resolved
|
||
private func shouldStartRotating(with velocity: CGFloat, deltaSinceStart: CGFloat) -> Bool { | ||
let deltaSinceStartInDegrees = deltaSinceStart.toDegrees() | ||
let velocityInDegreesPerMillisecond = abs(velocity) * 0.057295779513082 |
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.
Please make this magic number a const variable.
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.
Converted to formula 👍
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.
LGTM
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.
There is a rotation issue during my tests. The attached video is 1/3 playback speed.
Rotation.junk.-.x1.3.slow.mp4
mapboxMap.setCamera( | ||
to: CameraOptions( | ||
anchor: focalPoint ?? midpoint, | ||
bearing: (initialBearing + rotationInDegrees).truncatingRemainder(dividingBy: 360.0)) |
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.
Looks like we can use wrapped
here:
bearing: (initialBearing + rotationInDegrees).truncatingRemainder(dividingBy: 360.0)) | |
bearing: (initialBearing + rotationInDegrees).wrapped(to: 0..<(2 * .pi))) |
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.
Changed it to (initialBearing + rotationInDegrees).wrapped(to: 0..<360)
isMapRotating = true | ||
// pretend to be pinch gesture for backwards compatibility | ||
delegate?.gestureBegan(for: .pinch) |
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.
Why do we ignore the began
state for this event/flag?
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.
Delegate is notified when we actually start/end rotating the map, in order to get raw gesture recogniser events one would need to subscribe to the gesture recogniser directly, e.g.:
mapView.gestures.rotateGestureRecognizer.addTarget(self, action: #selector(handleRotationUpdate(_:)))
Sources/MapboxMaps/Gestures/GestureHandlers/RotateGestureHandler.swift
Outdated
Show resolved
Hide resolved
* Update changelog (#1418) * Add style toggle to location example (#1413) * [XCParty] Add tag name if HEAD has any (#1424) * [XCParty] Export crash reports for XCResult (#1434) * Expose a way to initialise TilesetDescriptorOptionsForTilesets (#1431) * Add cast shadow option to 3d puck config (#1435) * Mark camera functions as unsupported for globe projection, invocation results in a no-op (#1440) * Rotation gesture threshold and simultaneousRotateAndPinchToZoomEnabled option (#1429) * Add option to support measurements from the only last run (#1445) * Update examples (#1443) * Fix flaky test (#1450) * Fix view annotation losing its feature association after update (#1446) * Enable `modelCastsShadow` option for custom location puck config (#1447) * enabled model casts shadows option for custom location puck configuration * Provide default value for list of last-run metrics (#1453) * Update CoreMaps to `10.7.0-rc.1` (#1456) * Update CoreMaps to 10.7.0-rc.1 * Update changelog * Update changelog header (#1459) * Update 10.7.0 versions (#1460) Co-authored-by: ZiZi <44972592+ZiZasaurus@users.noreply.github.com> Co-authored-by: Roman Laitarenko <roman.laitarenko@mapbox.com> Co-authored-by: Tobrun <tobrun.van.nuland@gmail.com>
* Add style toggle to location example (#1413) * [XCParty] Add tag name if HEAD has any (#1424) * [XCParty] Export crash reports for XCResult (#1434) * Expose a way to initialise TilesetDescriptorOptionsForTilesets (#1431) * Add cast shadow option to 3d puck config (#1435) * Mark camera functions as unsupported for globe projection, invocation results in a no-op (#1440) * Rotation gesture threshold and simultaneousRotateAndPinchToZoomEnabled option (#1429) * Add option to support measurements from the only last run (#1445) * Update examples (#1443) * Fix flaky test (#1450) * Fix view annotation losing its feature association after update (#1446) * Enable `modelCastsShadow` option for custom location puck config (#1447) * enabled model casts shadows option for custom location puck configuration * Provide default value for list of last-run metrics (#1453) * Update CoreMaps to `10.7.0-rc.1` (#1456) * Update CoreMaps to 10.7.0-rc.1 * Update changelog * Update changelog header (#1459) * Update 10.7.0 versions (#1460) Co-authored-by: ZiZi <44972592+ZiZasaurus@users.noreply.github.com> Co-authored-by: Roman Laitarenko <roman.laitarenko@mapbox.com> Co-authored-by: Tobrun <tobrun.van.nuland@gmail.com>
This PR adds filtering to rotation gesture handling - the map won't start rotating unless rotation magnitude/velocity exceeds certain level/combination of the two. This is done to prevent the map from being rotated accidentally while being zoomed.
Along this change rotation handling was delegated to a dedicated handler/recogniser which led to
GestureOptions.pinchRotateEnabled
being deprecated in favour ofGestureOptions.rotateEnabled
(this also brings Android and iOS closer in terms of gesture options API).Additionally this PR adds an option to disable simultaneous rotation and pinch zooming
GestureOptions.simultaneousRotateAndPinchToZoomEnabled
.RPReplay_Final1657028966.MP4
RPReplay_Final1657029054.MP4
Pull request checklist:
## main
heading near the top).