Skip to content

Commit

Permalink
chore: Improve MapView navigation animation
Browse files Browse the repository at this point in the history
  • Loading branch information
fedirjh committed Jun 22, 2024
1 parent 414f596 commit 8d1ae21
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/components/MapView/MapView.website.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -112,14 +112,13 @@ const MapView = forwardRef<MapViewHandle, ComponentProps>(
return;
}

// Avoid navigationg to the same location
if (prevUserPosition.longitude === currentPosition.longitude && prevUserPosition.latitude === currentPosition.latitude) {
return;
}
// Avoid animating the naviagtion to the same location
const shouldAnimate = prevUserPosition.longitude !== currentPosition.longitude || prevUserPosition.latitude !== currentPosition.latitude;

mapRef.flyTo({
center: [currentPosition.longitude, currentPosition.latitude],
zoom: CONST.MAPBOX.DEFAULT_ZOOM,
animate: shouldAnimate,
});
}, [currentPosition, mapRef, prevUserPosition, shouldPanMapToCurrentPosition]);

Expand Down

0 comments on commit 8d1ae21

Please sign in to comment.