From c86acab61f9a902c329b0ce57e4526fe95cd6ebe 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 442e6418e4..5cf940f6af 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 35e142e7c6..ee56d721af 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 }