From d02c9afe9cdf827ee51ba3f18b01a1de4f532849 Mon Sep 17 00:00:00 2001 From: Clara Ni Date: Thu, 17 Oct 2024 16:22:48 +0200 Subject: [PATCH 1/2] ui-manchette-with-spacetimechart: add resetZoom callback Signed-off-by: Clara Ni --- .../src/hooks/useManchetteWithSpaceTimeChart.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/ui-manchette-with-spacetimechart/src/hooks/useManchetteWithSpaceTimeChart.ts b/ui-manchette-with-spacetimechart/src/hooks/useManchetteWithSpaceTimeChart.ts index 25066476c..0c109f472 100644 --- a/ui-manchette-with-spacetimechart/src/hooks/useManchetteWithSpaceTimeChart.ts +++ b/ui-manchette-with-spacetimechart/src/hooks/useManchetteWithSpaceTimeChart.ts @@ -100,6 +100,10 @@ const useManchettesWithSpaceTimeChart = ( } }, [yZoom]); + const resetZoom = useCallback(() => { + setState((prev) => ({ ...prev, yZoom: 1 })); + }, []); + const handleScroll = useCallback(() => { if (!isShiftPressed && manchetteWithSpaceTimeChartContainer.current) { const { scrollTop } = manchetteWithSpaceTimeChartContainer.current; @@ -146,11 +150,12 @@ const useManchettesWithSpaceTimeChart = ( operationalPoints: operationalPointsWithHeight, zoomYIn, zoomYOut, + resetZoom, toggleMode, yZoom, isProportional, }), - [operationalPointsWithHeight, zoomYIn, zoomYOut, toggleMode, yZoom, isProportional] + [operationalPointsWithHeight, zoomYIn, zoomYOut, resetZoom, toggleMode, yZoom, isProportional] ); // Memoize spaceTimeChartProps separately From 5ee4d9fd34325dd2f1922f7f335b9201442c34d8 Mon Sep 17 00:00:00 2001 From: Clara Ni Date: Thu, 17 Oct 2024 16:11:19 +0200 Subject: [PATCH 2/2] ui-manchette: add fit button Signed-off-by: Clara Ni --- ui-manchette/src/components/Manchette.tsx | 25 ++++++------- .../src/stories/Manchette.stories.tsx | 1 + ui-manchette/src/styles/manchette.css | 36 ++++++++++++++----- 3 files changed, 38 insertions(+), 24 deletions(-) diff --git a/ui-manchette/src/components/Manchette.tsx b/ui-manchette/src/components/Manchette.tsx index 185635d39..6d060f5e6 100644 --- a/ui-manchette/src/components/Manchette.tsx +++ b/ui-manchette/src/components/Manchette.tsx @@ -12,6 +12,7 @@ type ManchetteProps = { activeOperationalPointId?: string; zoomYIn: () => void; zoomYOut: () => void; + resetZoom: () => void; height?: number; yZoom?: number; children?: React.ReactNode; @@ -22,6 +23,7 @@ type ManchetteProps = { const Manchette = ({ zoomYIn, zoomYOut, + resetZoom, yZoom = 1, operationalPoints, activeOperationalPointId, @@ -31,7 +33,7 @@ const Manchette = ({ }: ManchetteProps) => (
{children}
-
-
- -
-
- +