-
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
Zoom focal point #1122
Merged
Merged
Zoom focal point #1122
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
fa4a4ce
Add focal point override support to double-tap-to-zoom-in gesture
evil159 683f0e9
Add focal point override support to double-touch-to-zoom-out gesture
evil159 36ba6d1
Add focal point override support to quick zoom gesture
evil159 80a218d
Add focal point override support to pinch gesture
evil159 54f9c8b
Add zoom gestures focal point unit tests
evil159 e0728c9
Add change log entry
evil159 5a500be
Lint
evil159 ea8209e
Add focal point option tests
evil159 4fae475
Update change log entry
evil159 4687fbe
Introduce ZoomGestureHandlerProtocol for common zoom-related gesture …
evil159 f68b927
Address PR feedback
evil159 723166b
Address PR feedback
evil159 6e88547
Another round of addressing PR feedback
evil159 5098920
Another round of addressing PR feedback
evil159 e63bf0a
Remove useless import
evil159 75ffef8
Remove now obselete unit tests
evil159 d7a1486
Update Sources/MapboxMaps/Gestures/GestureOptions.swift
evil159 0b6965b
Merge branch 'main' into zoom-focal-point
evil159 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
5 changes: 5 additions & 0 deletions
5
Sources/MapboxMaps/Gestures/GestureHandlers/FocusableGestureHandlerProtocol.swift
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import Foundation | ||
|
||
internal protocol FocusableGestureHandlerProtocol: GestureHandler { | ||
var focalPoint: CGPoint? { get set } | ||
} |
2 changes: 2 additions & 0 deletions
2
Sources/MapboxMaps/Gestures/GestureHandlers/PinchBehaviors/PanRotatePinchBehavior.swift
This file contains 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
2 changes: 2 additions & 0 deletions
2
Sources/MapboxMaps/Gestures/GestureHandlers/PinchBehaviors/PanZoomPinchBehavior.swift
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,11 @@ | ||
import UIKit | ||
@_implementationOnly import MapboxCommon_Private | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This import can be removed now There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This one stays, but the one from |
||
|
||
internal protocol PinchGestureHandlerProtocol: GestureHandler { | ||
internal protocol PinchGestureHandlerProtocol: FocusableGestureHandlerProtocol { | ||
var rotateEnabled: Bool { get set } | ||
var zoomEnabled: Bool { get set } | ||
var panEnabled: Bool { get set } | ||
var focalPoint: CGPoint? { get set } | ||
} | ||
|
||
/// `PinchGestureHandler` updates the map camera in response to a 2-touch | ||
|
@@ -18,6 +20,9 @@ internal final class PinchGestureHandler: GestureHandler, PinchGestureHandlerPro | |
/// Whether pinch gesture can pan map or not | ||
internal var panEnabled: Bool = true | ||
|
||
/// Anchor point for rotating and zooming | ||
internal var focalPoint: CGPoint? | ||
|
||
/// The behavior for the current gesture, based on the initial state of the \*Enabled flags. | ||
private var pinchBehavior: PinchBehavior? | ||
|
||
|
@@ -86,13 +91,21 @@ internal final class PinchGestureHandler: GestureHandler, PinchGestureHandlerPro | |
guard let view = gestureRecognizer.view else { | ||
return | ||
} | ||
|
||
if panEnabled, focalPoint != nil { | ||
Log.warning( | ||
forMessage: "Possible pinch gesture recognizer misconfiguration: the specified focal point will be ignored when pinching. In order for the focal point to work, pinch pan has to be disabled.", | ||
category: "Gestures") | ||
} | ||
|
||
pinchBehavior = pinchBehaviorProvider.makePinchBehavior( | ||
panEnabled: panEnabled, | ||
zoomEnabled: zoomEnabled, | ||
rotateEnabled: rotateEnabled, | ||
initialCameraState: mapboxMap.cameraState, | ||
initialPinchMidpoint: gestureRecognizer.location(in: view), | ||
initialPinchAngle: pinchAngle(with: gestureRecognizer)) | ||
initialPinchAngle: pinchAngle(with: gestureRecognizer), | ||
focalPoint: focalPoint) | ||
// if this is the first time we started handling the gesture, inform | ||
// the delegate. | ||
if !invokedGestureBegan { | ||
|
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.
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.
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.
nit: I'm not familiar with swift, but is it needed as there's no other change in this class besides this import.
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.
Xcode has started auto-importing frameworks which is leading to a lot of things like this happening. Probably there were other changes to this file in a previous iteration of this PR which led to this import which was then not reverted.
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.
@macdrevx exactly! I'm willing to keep it, Xcode has a point - we do use
CoreGrapics
types here.