Skip to content

Commit

Permalink
DBC22-528: fix double panning on click
Browse files Browse the repository at this point in the history
  • Loading branch information
ray-oxd committed Apr 3, 2024
1 parent 4019a86 commit df96c42
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 11 deletions.
16 changes: 6 additions & 10 deletions src/frontend/src/Components/Map.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ export default function MapWrapper({
restStops,
restStopsTimeStamp, // Rest Stops
searchLocationFrom,
searchLocationTo,
selectedRoute, // Routing
zoom,
pan, // Map
Expand Down Expand Up @@ -146,6 +147,7 @@ export default function MapWrapper({
restStopsTimeStamp: state.feeds.restStops.routeTimeStamp,
// Routing
searchLocationFrom: state.routes.searchLocationFrom,
searchLocationTo: state.routes.searchLocationTo,
selectedRoute: state.routes.selectedRoute,
// Map
zoom: state.map.zoom,
Expand Down Expand Up @@ -623,17 +625,11 @@ export default function MapWrapper({
// store the initial searchLocationFrom.[0].label so that subsequent
// runs can be evaluated to detect change in the search from
isInitialMountLocation.current = searchLocationFrom[0].label;
} else if (
isInitialMountLocation.current !== searchLocationFrom[0].label
) {
// only zoomPan on a real change in the search location from; this makes
// this effector idempotent wrt state

// only zoomPan on from location change when to location is NOT set
} else if (isInitialMountLocation.current !== searchLocationFrom[0].label && searchLocationTo.length == 0) {
isInitialMountLocation.current = false;
setZoomPan(
mapView,
9,
fromLonLat(searchLocationFrom[0].geometry.coordinates),
);
setZoomPan(mapView, 9, fromLonLat(searchLocationFrom[0].geometry.coordinates));
}
} else {
// initial location was set, so no need to prevent pan/zoom
Expand Down
2 changes: 1 addition & 1 deletion src/frontend/src/Components/map/helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export const setZoomPan = (mapView, zoom, panCoords) => {
}

const args = {
duration: 750
duration: 1000
};

if (zoom) {
Expand Down

0 comments on commit df96c42

Please sign in to comment.