Skip to content

Commit

Permalink
docs: remove dragging threshold when interacting with custom elements…
Browse files Browse the repository at this point in the history
… (#5240)
  • Loading branch information
ad1992 authored May 24, 2022
1 parent d08179c commit 269fbcc
Showing 1 changed file with 15 additions and 23 deletions.
38 changes: 15 additions & 23 deletions src/packages/excalidraw/example/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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) => {
Expand Down

0 comments on commit 269fbcc

Please sign in to comment.