Skip to content

Commit

Permalink
fix: Pass the topRight offset value to fixedZoomDrawerOffsetAutoCenter
Browse files Browse the repository at this point in the history
  • Loading branch information
joshlarson committed Nov 20, 2023
1 parent ac3118f commit b8089c4
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
7 changes: 3 additions & 4 deletions assets/src/components/map/follower.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -223,9 +223,8 @@ export const drawerOffsetAutoCenter =
}
}

export const fixedZoomDrawerOffsetAutoCenter = drawerOffsetAutoCenter(
false,
[0, 0]
)
export const fixedZoomDrawerOffsetAutoCenter = (
topLeft: PointExpression | undefined
) => drawerOffsetAutoCenter(false, topLeft || [0, 0])

// #endregion Follower Update Functions
9 changes: 6 additions & 3 deletions assets/src/components/mapPage/mapDisplay.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -178,9 +178,10 @@ const useLiveSelectedEntity = (
const MapElementsNoSelection = () => {
const followerState = useFollowingStateWithSelectionLogic(null, null)

const { paddingTopLeft } = useContext(MapSafeAreaContext)
return (
<RecenterControlWithInterruptibleFollower
onUpdate={fixedZoomDrawerOffsetAutoCenter}
onUpdate={fixedZoomDrawerOffsetAutoCenter(paddingTopLeft)}
positions={[]}
{...followerState}
/>
Expand Down Expand Up @@ -365,6 +366,7 @@ const SelectedRouteDataLayers = ({
(selectedRoutePattern?.shape?.stops || []).map((s) => s.id)
)

const { paddingTopLeft } = useContext(MapSafeAreaContext)
return (
<>
{selectedRoutePattern && (
Expand All @@ -379,7 +381,7 @@ const SelectedRouteDataLayers = ({
onVehicleSelect={selectVehicle}
/>
<RecenterControlWithInterruptibleFollower
onUpdate={fixedZoomDrawerOffsetAutoCenter}
onUpdate={fixedZoomDrawerOffsetAutoCenter(paddingTopLeft)}
positions={routeShapePositions}
{...followerState}
/>
Expand All @@ -397,11 +399,12 @@ const SelectedLocationDataLayer = ({
}) => {
const followerState = useInteractiveFollowerState()

const { paddingTopLeft } = useContext(MapSafeAreaContext)
return (
<>
<LocationMarker location={location} selected={true} />
<RecenterControlWithInterruptibleFollower
onUpdate={fixedZoomDrawerOffsetAutoCenter}
onUpdate={fixedZoomDrawerOffsetAutoCenter(paddingTopLeft)}
positions={[Leaflet.latLng(location.latitude, location.longitude)]}
{...followerState}
/>
Expand Down

0 comments on commit b8089c4

Please sign in to comment.