@@ -6,7 +6,6 @@ import type {
66 SpaceTimeChartProps ,
77} from '@osrd-project/ui-spacetimechart/dist/lib/types' ;
88
9- import { useIsOverflow } from './useIsOverFlow' ;
109import usePaths from './usePaths' ;
1110import { MAX_ZOOM_Y , MIN_ZOOM_Y , ZOOM_Y_DELTA , INITIAL_SPACE_TIME_CHART_HEIGHT } from '../consts' ;
1211import {
@@ -28,7 +27,6 @@ type State = {
2827 scrollPosition : number ;
2928 isProportional : boolean ;
3029 waypointsChart : Waypoint [ ] ;
31- panY : boolean ;
3230 scales : SpaceScale [ ] ;
3331} ;
3432
@@ -49,19 +47,13 @@ const useManchettesWithSpaceTimeChart = (
4947 scrollPosition : 0 ,
5048 isProportional : true ,
5149 waypointsChart : [ ] ,
52- panY : false ,
5350 scales : [ ] ,
5451 } ) ;
5552
56- const { xZoom, yZoom, xOffset, yOffset, panY , panning, scrollPosition, isProportional } = state ;
53+ const { xZoom, yZoom, xOffset, yOffset, panning, scrollPosition, isProportional } = state ;
5754
5855 const paths = usePaths ( projectPathTrainResult , selectedTrain ) ;
5956
60- const checkOverflow = useCallback ( ( isOverflowFromCallback : boolean ) => {
61- setState ( ( prev ) => ( { ...prev , panY : isOverflowFromCallback } ) ) ;
62- } , [ ] ) ;
63- useIsOverflow ( manchetteWithSpaceTimeChartContainer , checkOverflow ) ;
64-
6557 // Memoize timeWindow to avoid recalculation on each render
6658 const timeWindow = useMemo (
6759 ( ) => computeTimeWindow ( projectPathTrainResult ) ,
@@ -184,18 +176,17 @@ const useManchettesWithSpaceTimeChart = (
184176 } else {
185177 const { initialOffset } = panning ;
186178 newState . xOffset = initialOffset . x + diff . x ;
187- if ( panY ) {
188- const newYPos = initialOffset . y - diff . y ;
189- if (
190- manchetteWithSpaceTimeChartContainer . current &&
191- newYPos >= 0 &&
192- newYPos + INITIAL_SPACE_TIME_CHART_HEIGHT <=
193- manchetteWithSpaceTimeChartContainer . current . scrollHeight
194- ) {
195- newState . yOffset = newYPos ;
196- newState . scrollPosition = newYPos ;
197- manchetteWithSpaceTimeChartContainer . current . scrollTop = newYPos ;
198- }
179+
180+ const newYPos = initialOffset . y - diff . y ;
181+ if (
182+ manchetteWithSpaceTimeChartContainer . current &&
183+ newYPos >= 0 &&
184+ newYPos + INITIAL_SPACE_TIME_CHART_HEIGHT <=
185+ manchetteWithSpaceTimeChartContainer . current . scrollHeight
186+ ) {
187+ newState . yOffset = newYPos ;
188+ newState . scrollPosition = newYPos ;
189+ manchetteWithSpaceTimeChartContainer . current . scrollTop = newYPos ;
199190 }
200191 }
201192 setState ( newState ) ;
@@ -208,7 +199,6 @@ const useManchettesWithSpaceTimeChart = (
208199 xZoom ,
209200 paths ,
210201 xOffset ,
211- panY ,
212202 scrollPosition ,
213203 isShiftPressed ,
214204 state ,
0 commit comments