Skip to content

Commit

Permalink
[core] Ignore shortest path when gesturing in Transform::easeTo
Browse files Browse the repository at this point in the history
If gesture in progress, we transfer the world rounds from the end
longitude into start, so we can guarantee the "scroll effect" of
rounding the world while assuring the end longitude remains wrapped.
Otherwise, find the shortest path.
  • Loading branch information
brunoabinader committed Mar 14, 2016
1 parent b5bb48e commit 78a12d9
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/mbgl/map/transform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,8 @@ void Transform::jumpTo(const CameraOptions& camera) {
* not included in `options`.
*/
void Transform::easeTo(const CameraOptions& camera, const AnimationOptions& animation) {
const LatLng latLng = camera.center.value_or(getLatLng()).wrapped();
const LatLng unwrappedLatLng = camera.center.value_or(getLatLng());
const LatLng latLng = unwrappedLatLng.wrapped();
double zoom = camera.zoom.value_or(getZoom());
double angle = camera.angle.value_or(getAngle());
double pitch = camera.pitch.value_or(getPitch());
Expand All @@ -89,8 +90,13 @@ void Transform::easeTo(const CameraOptions& camera, const AnimationOptions& anim
// Determine endpoints.
EdgeInsets padding;
if (camera.padding) padding = *camera.padding;
LatLng startLatLng = getLatLng(padding).wrapped();
startLatLng.unwrapForShortestPath(latLng);
LatLng startLatLng = getLatLng(padding);
// If gesture in progress, we transfer the world rounds from the end
// longitude into start, so we can guarantee the "scroll effect" of rounding
// the world while assuring the end longitude remains wrapped.
if (isGestureInProgress()) startLatLng.longitude -= unwrappedLatLng.longitude - latLng.longitude;
// Find the shortest path otherwise.
else startLatLng.unwrapForShortestPath(latLng);

const ScreenCoordinate startPoint = {
state.lngX(startLatLng.longitude),
Expand Down

0 comments on commit 78a12d9

Please sign in to comment.