Repository navigation
Fix UserCourseView sliding - #1506
Conversation
| } | ||
|
|
||
| @objc private func disableUserCourseTracking() { | ||
| guard tracksUserCourse else { return } |
There was a problem hiding this comment.
disableUserCourseTracking() is called on every map move. We don't need to continually call didSet on tracksUserCourse.
| // Because of this, we need to set it before or it will create a camera for the current pitch instead of 0. | ||
| let camera = self.camera | ||
| camera.pitch = 0 | ||
| camera.heading = 0 |
There was a problem hiding this comment.
Minor improvement. We are now force setting only one camera property before calculating the correct camera for the line.
| UIView.animate(withDuration: duration, delay: 0, options: [.curveLinear, .beginFromCurrentState], animations: { | ||
| self.userCourseView?.center = self.convert(location.coordinate, toPointTo: self) | ||
| }, completion: nil) | ||
| self.userCourseView?.center = self.convert(location.coordinate, toPointTo: self) |
There was a problem hiding this comment.
This method gets called on every location update. So removing the UIView.animate(withDuration:delay:options:animation:) block means the course view never animates, even between user location updates. duration is either 1 or 0 depending on whether the caller wants animation.
In #1505, I meant that we should also call UIView.animate(withDuration:delay:options:animation:) with a duration of 0 elsewhere, to temporarily disable the implicit animation that happens whenever the view’s center changes.
| self.camera = camera | ||
|
|
||
| setVisibleCoordinateBounds(line.overlayBounds, edgePadding: bounds, animated: true) | ||
| let camerForLine = cameraThatFitsShape(line, direction: 0, edgePadding: bounds) |
| setCamera(newCamera, withDuration: duration, animationTimingFunction: function, edgePadding: padding, completionHandler: nil) | ||
| } else { | ||
| UIView.animate(withDuration: duration, delay: 0, options: [.curveLinear, .beginFromCurrentState], animations: { | ||
| UIView.animate(withDuration: 0, delay: 0, options: [.curveLinear, .beginFromCurrentState], animations: { |
There was a problem hiding this comment.
This suffers from the same problem mentioned in #1506 (comment): the puck can’t animate between user locations anymore.
| } else { | ||
| UIView.animate(withDuration: duration, delay: 0, options: [.curveLinear, .beginFromCurrentState], animations: { | ||
| // While animating to overhead mode, don't animate the puck. | ||
| UIView.animate(withDuration: isAnimatingToOverheadMode ? 0 : duration, delay: 0, options: [.curveLinear, .beginFromCurrentState], animations: { |
There was a problem hiding this comment.
This is fine, but it might be cleaner to have isAnimatingToOverheadMode affect duration up above:
let duration: TimeInterval = animated && !isAnimatingToOverheadMode ? 1 : 0There was a problem hiding this comment.
I think it will always be false here, but ok.
| camera.altitude = NavigationMapView.defaultAltitude | ||
| setCamera(camera, animated: true) | ||
| setCamera(camera, withDuration: 1, animationTimingFunction: nil) { | ||
| self.isAnimatingToOverheadMode = false |
|
Here’s a changelog blurb:
|
Closes: #1505
Fixes and adds a few optimizations around going into overhead mode. The sliding issue mainly is due to the fact we were animating to the position of the puck which is not necessary when going into overhead mode.
/cc @1ec5 @frederoni