fix(ui): brush spacing handling

This commit is contained in:
psychedelicious 2024-06-06 17:01:41 +10:00
parent b3fe03b8f9
commit 9982219d18

View File

@ -1,9 +1,5 @@
import { calculateNewBrushSize } from 'features/canvas/hooks/useCanvasZoom';
import {
getIsMouseDown,
getScaledFlooredCursorPosition,
snapPosToStage,
} from 'features/controlLayers/konva/util';
import { getIsMouseDown, getScaledFlooredCursorPosition, snapPosToStage } from 'features/controlLayers/konva/util';
import {
type AddBrushLineArg,
type AddEraserLineArg,
@ -74,9 +70,10 @@ const maybeAddNextPoint = (
if (lastAddedPoint) {
// Dispatching redux events impacts perf substantially - using brush spacing keeps dispatches to a reasonable number
if (Math.hypot(lastAddedPoint.x - currentPos.x, lastAddedPoint.y - currentPos.y) < $brushSpacingPx.get()) {
return null;
return;
}
}
$lastAddedPoint.set(currentPos);
onPointAddedToLine({ layerId, point: [currentPos.x, currentPos.y] });
};