Skip to content
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

Merged
merged 33 commits into from
Jul 12, 2022

Conversation

evil159
Copy link
Contributor

@evil159 evil159 commented Jul 5, 2022

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 of GestureOptions.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.

Before After
RPReplay_Final1657028966.MP4
RPReplay_Final1657029054.MP4

Pull request checklist:

  • Write tests for all new functionality. If tests were not written, please explain why.
  • Add documentation comments for any added or updated public APIs.
  • Describe the changes in this PR, especially public API changes.
  • Add a changelog entry to to bottom of the relevant section (typically the ## main heading near the top).
  • Review and agree to the Contributor License Agreement (CLA).

@evil159 evil159 requested review from Chaoba and kiryldz July 5, 2022 14:03
@evil159 evil159 requested a review from a team as a code owner July 5, 2022 14:03
@evil159 evil159 force-pushed the rl/MAPSIOS-210_rotation_v1.5 branch from 63d90ef to 1b3170d Compare July 5, 2022 14:13

private func shouldStartRotating(with velocity: CGFloat, deltaSinceStart: CGFloat) -> Bool {
let deltaSinceStartInDegrees = deltaSinceStart.toDegrees()
let velocityInDegreesPerMillisecond = abs(velocity) * 0.057295779513082
Copy link
Contributor

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Converted to formula 👍

@evil159 evil159 requested a review from Chaoba July 7, 2022 10:48
Copy link
Contributor

@Chaoba Chaoba left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

@OdNairy OdNairy left a 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))
Copy link
Contributor

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:

Suggested change
bearing: (initialBearing + rotationInDegrees).truncatingRemainder(dividingBy: 360.0))
bearing: (initialBearing + rotationInDegrees).wrapped(to: 0..<(2 * .pi)))

Copy link
Contributor Author

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)

Comment on lines +42 to +44
isMapRotating = true
// pretend to be pinch gesture for backwards compatibility
delegate?.gestureBegan(for: .pinch)
Copy link
Contributor

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?

Copy link
Contributor Author

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(_:)))

@evil159 evil159 requested a review from OdNairy July 12, 2022 09:37
@evil159 evil159 enabled auto-merge (squash) July 12, 2022 12:59
@evil159 evil159 merged commit 7364de8 into main Jul 12, 2022
@evil159 evil159 deleted the rl/MAPSIOS-210_rotation_v1.5 branch July 12, 2022 13:08
OdNairy added a commit that referenced this pull request Jul 14, 2022
* 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>
OdNairy added a commit that referenced this pull request Jul 14, 2022
* 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>
OdNairy pushed a commit that referenced this pull request Aug 22, 2023
OdNairy pushed a commit that referenced this pull request Aug 22, 2023
* Update TestLab devices list (#1429)

* Use iPhone 8 iOS 16.2 on TestLab (#1432)

* Replace iPhone 8 iOS 16.2 with iPhone 11 Pro iOS 16.2 (#1434)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants