diff --git a/front/src/modules/pathfinding/components/IncompatibleConstraints/IncompatibleConstraintsList.tsx b/front/src/modules/pathfinding/components/IncompatibleConstraints/IncompatibleConstraintsList.tsx index 5328c2492c..3d5be165eb 100644 --- a/front/src/modules/pathfinding/components/IncompatibleConstraints/IncompatibleConstraintsList.tsx +++ b/front/src/modules/pathfinding/components/IncompatibleConstraints/IncompatibleConstraintsList.tsx @@ -2,6 +2,9 @@ import { useMemo } from 'react'; import { debounce, sortBy } from 'lodash'; import { useMap } from 'react-map-gl/maplibre'; +import { useSelector } from 'react-redux'; + +import { getMap } from 'reducers/map/selectors'; import IncompatibleConstraintItem from './IncompatibleConstraintsItem'; import type { IncompatibleConstraintEnhanced } from './types'; @@ -21,6 +24,7 @@ const IncompatibleConstraintsList = ({ onHover, onSelect, }: IncompatibleConstraintListProps) => { + const { smoothTravel } = useSelector(getMap); const map = useMap(); const items = useMemo(() => sortBy(data, ['start', 'end']), [data]); @@ -40,7 +44,7 @@ const IncompatibleConstraintsList = ({ onClick={() => onSelect(item.id)} gotoMap={() => { if (!isSelected) onSelect(item.id); - map.current?.fitBounds(item.bbox); + map.current?.fitBounds(item.bbox, { animate: smoothTravel }); }} /> ); diff --git a/front/src/modules/pathfinding/components/IncompatibleConstraints/IncompatibleConstraintsMapFocus.tsx b/front/src/modules/pathfinding/components/IncompatibleConstraints/IncompatibleConstraintsMapFocus.tsx index dada04bac9..d8cfb2d32c 100644 --- a/front/src/modules/pathfinding/components/IncompatibleConstraints/IncompatibleConstraintsMapFocus.tsx +++ b/front/src/modules/pathfinding/components/IncompatibleConstraints/IncompatibleConstraintsMapFocus.tsx @@ -5,6 +5,9 @@ import bbox from '@turf/bbox'; import type { FeatureCollection, LineString } from '@turf/helpers'; import { useTranslation } from 'react-i18next'; import { useMap } from 'react-map-gl/maplibre'; +import { useSelector } from 'react-redux'; + +import { getMap } from 'reducers/map/selectors'; interface IncompatibleConstraintsMapFocusProps extends HTMLAttributes { geojson?: FeatureCollection; @@ -12,14 +15,17 @@ interface IncompatibleConstraintsMapFocusProps extends HTMLAttributes { const IncompatibleConstraintsMapFocus = (props: IncompatibleConstraintsMapFocusProps) => { const map = useMap(); + const { smoothTravel } = useSelector(getMap); const { t } = useTranslation(['operationalStudies/manageTrainSchedule']); const { geojson, ...attrs } = props; const mapFocusOnPath = useCallback(() => { if (geojson) { - map.current?.fitBounds(bbox(geojson) as [number, number, number, number]); + map.current?.fitBounds(bbox(geojson) as [number, number, number, number], { + animate: smoothTravel, + }); } - }, [map, geojson]); + }, [map, geojson, smoothTravel]); return (