From 0e7a945f3bb155e6b9843f15a3c08acdf45a5b5d Mon Sep 17 00:00:00 2001 From: Jim O'Donnell Date: Fri, 6 Dec 2024 13:00:09 +0000 Subject: [PATCH] revert changes to SingleImageViewer --- .../components/SingleImageViewer/SingleImageViewer.js | 5 ++++- .../plugins/drawingTools/components/draggable/draggable.js | 5 +++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/packages/lib-classifier/src/components/Classifier/components/SubjectViewer/components/SingleImageViewer/SingleImageViewer.js b/packages/lib-classifier/src/components/Classifier/components/SubjectViewer/components/SingleImageViewer/SingleImageViewer.js index b8d2547abef..6829d078a2c 100644 --- a/packages/lib-classifier/src/components/Classifier/components/SubjectViewer/components/SingleImageViewer/SingleImageViewer.js +++ b/packages/lib-classifier/src/components/Classifier/components/SubjectViewer/components/SingleImageViewer/SingleImageViewer.js @@ -34,10 +34,12 @@ function SingleImageViewer({ zoomControlFn = null, zooming = false }) { + const canvasLayer = useRef() + const canvas = canvasLayer.current const transform = `rotate(${rotate} ${width / 2} ${height / 2})` return ( - + {zoomControlFn && ( {children} diff --git a/packages/lib-classifier/src/plugins/drawingTools/components/draggable/draggable.js b/packages/lib-classifier/src/plugins/drawingTools/components/draggable/draggable.js index 35e142e7c60..ee56d721af4 100644 --- a/packages/lib-classifier/src/plugins/drawingTools/components/draggable/draggable.js +++ b/packages/lib-classifier/src/plugins/drawingTools/components/draggable/draggable.js @@ -16,8 +16,9 @@ function createPoint(event) { function getEventOffset(event, canvas) { const svgPoint = createPoint(event) - const svgEventOffset = svgPoint.matrixTransform - ? svgPoint.matrixTransform(canvas.getScreenCTM().inverse()) + const ctm = canvas?.getScreenCTM() + const svgEventOffset = ctm && svgPoint.matrixTransform + ? svgPoint.matrixTransform(ctm.inverse()) : svgPoint return svgEventOffset }