fix: mobile tapping to move cursor

This commit is contained in:
trafficlunar 2025-02-21 21:45:59 +00:00
parent ee94b224af
commit a301382515

View file

@ -173,19 +173,23 @@ function Canvas() {
[dragging, coords, scale, tool, mouseCoords, onToolUse, setCoords]
);
const onPointerDown = useCallback(() => {
dragging.current = true;
const onPointerDown = useCallback(
(e: React.MouseEvent) => {
dragging.current = true;
onToolUse();
updateCssCursor();
onToolUse();
onPointerMove(e);
updateCssCursor();
dragStartCoordsRef.current = mouseCoords;
startBlocksRef.current = [...blocks];
startSelectionCoordsRef.current = [...selectionCoords];
dragStartCoordsRef.current = mouseCoords;
startBlocksRef.current = [...blocks];
startSelectionCoordsRef.current = [...selectionCoords];
// Clear selection on click
if (tool === "rectangle-select") setSelectionCoords([]);
}, [onToolUse, updateCssCursor, mouseCoords, blocks, selectionCoords, tool, setSelectionCoords]);
// Clear selection on click
if (tool === "rectangle-select") setSelectionCoords([]);
},
[onToolUse, updateCssCursor, mouseCoords, blocks, selectionCoords, tool, setSelectionCoords]
);
const onPointerUp = useCallback(() => {
dragging.current = false;