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] [dragging, coords, scale, tool, mouseCoords, onToolUse, setCoords]
); );
const onPointerDown = useCallback(() => { const onPointerDown = useCallback(
dragging.current = true; (e: React.MouseEvent) => {
dragging.current = true;
onToolUse(); onToolUse();
updateCssCursor(); onPointerMove(e);
updateCssCursor();
dragStartCoordsRef.current = mouseCoords; dragStartCoordsRef.current = mouseCoords;
startBlocksRef.current = [...blocks]; startBlocksRef.current = [...blocks];
startSelectionCoordsRef.current = [...selectionCoords]; startSelectionCoordsRef.current = [...selectionCoords];
// Clear selection on click // Clear selection on click
if (tool === "rectangle-select") setSelectionCoords([]); if (tool === "rectangle-select") setSelectionCoords([]);
}, [onToolUse, updateCssCursor, mouseCoords, blocks, selectionCoords, tool, setSelectionCoords]); },
[onToolUse, updateCssCursor, mouseCoords, blocks, selectionCoords, tool, setSelectionCoords]
);
const onPointerUp = useCallback(() => { const onPointerUp = useCallback(() => {
dragging.current = false; dragging.current = false;