From 4053763e44fef6597b5332049a55627851c2340a Mon Sep 17 00:00:00 2001 From: Eric NGUYEN Date: Wed, 25 Jan 2023 15:33:49 +0100 Subject: [PATCH] Implement #7978: Add double click event to rescale and replace the viewer --- src/Components/SVG/SVG.tsx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Components/SVG/SVG.tsx b/src/Components/SVG/SVG.tsx index 4b49213..c56ce18 100644 --- a/src/Components/SVG/SVG.tsx +++ b/src/Components/SVG/SVG.tsx @@ -109,6 +109,9 @@ export function SVG(props: ISVGProps): JSX.Element { const value = event as Value; setScale(value.a); }} + onDoubleClick={() => { + svgViewer?.current?.setPointOnViewerCenter(props.width / 2, props.height / 2, 0.8); + }} background={'#ffffff'} defaultTool='pan' miniatureProps={{ @@ -131,6 +134,7 @@ export function SVG(props: ISVGProps): JSX.Element { function UseFitOnce(svgViewer: React.RefObject, width: number, height: number): void { React.useEffect(() => { - svgViewer?.current?.fitToViewer(); + // TODO: Fix this + svgViewer?.current?.setPointOnViewerCenter(width / 2, height / 2, 0.8); }, [svgViewer, width, height]); }