Skip to content

Fix UserCourseView sliding - #1506

Merged
bsudekum merged 6 commits into
masterfrom
fix-user-course
Jun 19, 2018
Merged

bsudekum merged 6 commits into
masterfrom
fix-user-course

Conversation

@bsudekum

Copy link
Copy Markdown
Contributor

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

}

@objc private func disableUserCourseTracking() {
guard tracksUserCourse else { return }

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Minor improvement. We are now force setting only one camera property before calculating the correct camera for the line.

@bsudekum bsudekum mentioned this pull request Jun 19, 2018
1 task done
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)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@1ec5 fixed.

self.camera = camera

setVisibleCoordinateBounds(line.overlayBounds, edgePadding: bounds, animated: true)
let camerForLine = cameraThatFitsShape(line, direction: 0, edgePadding: bounds)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Typo: camer.

Bobby Sudekum added 2 commits June 19, 2018 08:40
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: {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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: {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This is fine, but it might be cleaner to have isAnimatingToOverheadMode affect duration up above:

let duration: TimeInterval = animated && !isAnimatingToOverheadMode ? 1 : 0

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Weak self? (×2)

@1ec5

1ec5 commented Jun 19, 2018 •

Copy link
Copy Markdown
Contributor

Here’s a changelog blurb:

Fixed an issue where the user location view slid around after the user pressed the Overview button.

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.

2 participants