Skip to content

Commit

Permalink
fix: Vertically center the map on mobile when opening it
Browse files Browse the repository at this point in the history
  • Loading branch information
PolariTOON committed Jun 23, 2022
1 parent 59f73e2 commit 5edb53b
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/components/Trip/TripMap.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ const TripMap = () => {
[theme]
)
const mapPanRatio = useMemo(
() => (isMobile ? bottomSheetSettings.mediumHeightRatio / 2 : 0),
() => (isMobile ? bottomSheetSettings.mediumHeightRatio : 0),
[isMobile]
)

Expand All @@ -63,8 +63,9 @@ const TripMap = () => {
useEffect(() => {
if (geojsonRef.current) {
const geojsonL = geojsonRef.current.leafletElement
mapL.fitBounds(geojsonL.getBounds())
mapL.panBy([0, mapL.getSize().y * mapPanRatio])
mapL.fitBounds(geojsonL.getBounds(), {
paddingBottomRight: [0, mapL.getSize().y * mapPanRatio]
})
}
}, [mapL, mapPanRatio])

Expand Down

0 comments on commit 5edb53b

Please sign in to comment.