docs: remove dragging threshold when interacting with custom elements (#5240)

This commit is contained in:
Aakansha Doshi 2022-05-24 20:56:01 +05:30 committed by GitHub
parent d08179c215
commit 269fbcc2f3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -10,7 +10,7 @@ import {
withBatchedUpdates, withBatchedUpdates,
withBatchedUpdatesThrottled, withBatchedUpdatesThrottled,
} from "../../../utils"; } from "../../../utils";
import { DRAGGING_THRESHOLD, EVENT } from "../../../constants"; import { EVENT } from "../../../constants";
import { distance2d } from "../../../math"; import { distance2d } from "../../../math";
import { fileOpen } from "../../../data/filesystem"; import { fileOpen } from "../../../data/filesystem";
import { loadSceneOrLibraryFromBlob } from "../../utils"; import { loadSceneOrLibraryFromBlob } from "../../utils";
@ -264,29 +264,21 @@ export default function App() {
const onPointerMoveFromPointerDownHandler = (pointerDownState) => { const onPointerMoveFromPointerDownHandler = (pointerDownState) => {
return withBatchedUpdatesThrottled((event) => { return withBatchedUpdatesThrottled((event) => {
const distance = distance2d( const { x, y } = viewportCoordsToSceneCoords(
pointerDownState.x, {
pointerDownState.y, clientX: event.clientX - pointerDownState.hitElementOffsets.x,
event.clientX, clientY: event.clientY - pointerDownState.hitElementOffsets.y,
event.clientY, },
excalidrawAPI.getAppState(),
); );
if (distance > DRAGGING_THRESHOLD) { setCommentIcons({
const { x, y } = viewportCoordsToSceneCoords( ...commentIcons,
{ [pointerDownState.hitElement.id]: {
clientX: event.clientX - pointerDownState.hitElementOffsets.x, ...commentIcons[pointerDownState.hitElement.id],
clientY: event.clientY - pointerDownState.hitElementOffsets.y, x,
}, y,
excalidrawAPI.getAppState(), },
); });
setCommentIcons({
...commentIcons,
[pointerDownState.hitElement.id]: {
...commentIcons[pointerDownState.hitElement.id],
x,
y,
},
});
}
}); });
}; };
const onPointerUpFromPointerDownHandler = (pointerDownState) => { const onPointerUpFromPointerDownHandler = (pointerDownState) => {