From 9f60321c92e91ae48f5f534ea33b29647458be49 Mon Sep 17 00:00:00 2001 From: Jim O'Donnell Date: Mon, 16 Dec 2024 12:17:12 +0000 Subject: [PATCH] decorate draggable event handlers --- .../components/InteractionLayer/InteractionLayer.js | 1 + .../plugins/drawingTools/components/draggable/draggable.js | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/packages/lib-classifier/src/components/Classifier/components/SubjectViewer/components/InteractionLayer/InteractionLayer.js b/packages/lib-classifier/src/components/Classifier/components/SubjectViewer/components/InteractionLayer/InteractionLayer.js index a11b982ff7..1ec9ee978b 100644 --- a/packages/lib-classifier/src/components/Classifier/components/SubjectViewer/components/InteractionLayer/InteractionLayer.js +++ b/packages/lib-classifier/src/components/Classifier/components/SubjectViewer/components/InteractionLayer/InteractionLayer.js @@ -142,6 +142,7 @@ function InteractionLayer({ function onFinish(event) { event?.preventDefault?.() + event?.stopPropagation?.() setCreating(false) } 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 b4b1fda3f4..49aace6181 100644 --- a/packages/lib-classifier/src/plugins/drawingTools/components/draggable/draggable.js +++ b/packages/lib-classifier/src/plugins/drawingTools/components/draggable/draggable.js @@ -46,6 +46,9 @@ function draggable(WrappedComponent) { dragStart = DEFAULT_HANDLER, dragMove = DEFAULT_HANDLER, dragEnd = DEFAULT_HANDLER, + onPointerDown, + onPointerMove, + onPointerUp, ...rest }, ref) { const { canvas } = useContext(SVGContext) @@ -62,6 +65,7 @@ function draggable(WrappedComponent) { setDragging(true) pointerId.current = event.pointerId dragStart({ x, y, pointerId: event.pointerId }) + onPointerDown?.(event) wrappedComponent.current?.setPointerCapture(event.pointerId) } @@ -76,6 +80,7 @@ function draggable(WrappedComponent) { dragMove({ currentTarget, x, y, pointerId: event.pointerId }, difference) coords.current = { x, y } } + onPointerMove?.(event) } function onDragEnd(event) { @@ -87,6 +92,7 @@ function draggable(WrappedComponent) { coords.current = { x: null, y: null } setDragging(false) pointerId.current = -1 + onPointerUp?.(event) } return (