From 269fbcc2f33fb30a3a9208ae5857c262e3d8be3d Mon Sep 17 00:00:00 2001 From: Aakansha Doshi Date: Tue, 24 May 2022 20:56:01 +0530 Subject: [PATCH] docs: remove dragging threshold when interacting with custom elements (#5240) --- src/packages/excalidraw/example/App.js | 38 ++++++++++---------------- 1 file changed, 15 insertions(+), 23 deletions(-) diff --git a/src/packages/excalidraw/example/App.js b/src/packages/excalidraw/example/App.js index 9dbfc973..edb94956 100644 --- a/src/packages/excalidraw/example/App.js +++ b/src/packages/excalidraw/example/App.js @@ -10,7 +10,7 @@ import { withBatchedUpdates, withBatchedUpdatesThrottled, } from "../../../utils"; -import { DRAGGING_THRESHOLD, EVENT } from "../../../constants"; +import { EVENT } from "../../../constants"; import { distance2d } from "../../../math"; import { fileOpen } from "../../../data/filesystem"; import { loadSceneOrLibraryFromBlob } from "../../utils"; @@ -264,29 +264,21 @@ export default function App() { const onPointerMoveFromPointerDownHandler = (pointerDownState) => { return withBatchedUpdatesThrottled((event) => { - const distance = distance2d( - pointerDownState.x, - pointerDownState.y, - event.clientX, - event.clientY, + const { x, y } = viewportCoordsToSceneCoords( + { + clientX: event.clientX - pointerDownState.hitElementOffsets.x, + clientY: event.clientY - pointerDownState.hitElementOffsets.y, + }, + excalidrawAPI.getAppState(), ); - if (distance > DRAGGING_THRESHOLD) { - const { x, y } = viewportCoordsToSceneCoords( - { - clientX: event.clientX - pointerDownState.hitElementOffsets.x, - clientY: event.clientY - pointerDownState.hitElementOffsets.y, - }, - excalidrawAPI.getAppState(), - ); - setCommentIcons({ - ...commentIcons, - [pointerDownState.hitElement.id]: { - ...commentIcons[pointerDownState.hitElement.id], - x, - y, - }, - }); - } + setCommentIcons({ + ...commentIcons, + [pointerDownState.hitElement.id]: { + ...commentIcons[pointerDownState.hitElement.id], + x, + y, + }, + }); }); }; const onPointerUpFromPointerDownHandler = (pointerDownState) => {