Skip to content
This repository was archived by the owner on Aug 5, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 0 additions & 32 deletions ui-manchette-with-spacetimechart/src/hooks/useIsOverFlow.ts

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import type {
SpaceTimeChartProps,
} from '@osrd-project/ui-spacetimechart/dist/lib/types';

import { useIsOverflow } from './useIsOverFlow';
import usePaths from './usePaths';
import { MAX_ZOOM_Y, MIN_ZOOM_Y, ZOOM_Y_DELTA, INITIAL_SPACE_TIME_CHART_HEIGHT } from '../consts';
import {
Expand All @@ -28,7 +27,6 @@ type State = {
scrollPosition: number;
isProportional: boolean;
waypointsChart: Waypoint[];
panY: boolean;
scales: SpaceScale[];
};

Expand All @@ -49,19 +47,13 @@ const useManchettesWithSpaceTimeChart = (
scrollPosition: 0,
isProportional: true,
waypointsChart: [],
panY: false,
scales: [],
});

const { xZoom, yZoom, xOffset, yOffset, panY, panning, scrollPosition, isProportional } = state;
const { xZoom, yZoom, xOffset, yOffset, panning, scrollPosition, isProportional } = state;

const paths = usePaths(projectPathTrainResult, selectedTrain);

const checkOverflow = useCallback((isOverflowFromCallback: boolean) => {
setState((prev) => ({ ...prev, panY: isOverflowFromCallback }));
}, []);
useIsOverflow(manchetteWithSpaceTimeChartContainer, checkOverflow);

// Memoize timeWindow to avoid recalculation on each render
const timeWindow = useMemo(
() => computeTimeWindow(projectPathTrainResult),
Expand Down Expand Up @@ -184,18 +176,17 @@ const useManchettesWithSpaceTimeChart = (
} else {
const { initialOffset } = panning;
newState.xOffset = initialOffset.x + diff.x;
if (panY) {
const newYPos = initialOffset.y - diff.y;
if (
manchetteWithSpaceTimeChartContainer.current &&
newYPos >= 0 &&
newYPos + INITIAL_SPACE_TIME_CHART_HEIGHT <=
manchetteWithSpaceTimeChartContainer.current.scrollHeight
) {
newState.yOffset = newYPos;
newState.scrollPosition = newYPos;
manchetteWithSpaceTimeChartContainer.current.scrollTop = newYPos;
}

const newYPos = initialOffset.y - diff.y;
if (
manchetteWithSpaceTimeChartContainer.current &&
newYPos >= 0 &&
newYPos + INITIAL_SPACE_TIME_CHART_HEIGHT <=
manchetteWithSpaceTimeChartContainer.current.scrollHeight
) {
newState.yOffset = newYPos;
newState.scrollPosition = newYPos;
manchetteWithSpaceTimeChartContainer.current.scrollTop = newYPos;
}
}
setState(newState);
Expand All @@ -208,7 +199,6 @@ const useManchettesWithSpaceTimeChart = (
xZoom,
paths,
xOffset,
panY,
scrollPosition,
isShiftPressed,
state,
Expand Down
Loading