fix: freedraw slow movement jittery lines (#4726)

Co-authored-by: David Luzar <luzar.david@gmail.com>
This commit is contained in:
zsviczian 2022-02-06 17:45:23 +01:00 committed by GitHub
parent 98ea46664c
commit 96de887cc8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -3852,14 +3852,20 @@ class App extends React.Component<AppProps, AppState> {
const dx = pointerCoords.x - draggingElement.x;
const dy = pointerCoords.y - draggingElement.y;
const pressures = draggingElement.simulatePressure
? draggingElement.pressures
: [...draggingElement.pressures, event.pressure];
const lastPoint = points.length > 0 && points[points.length - 1];
const discardPoint =
lastPoint && lastPoint[0] === dx && lastPoint[1] === dy;
mutateElement(draggingElement, {
points: [...points, [dx, dy]],
pressures,
});
if (!discardPoint) {
const pressures = draggingElement.simulatePressure
? draggingElement.pressures
: [...draggingElement.pressures, event.pressure];
mutateElement(draggingElement, {
points: [...points, [dx, dy]],
pressures,
});
}
} else if (isLinearElement(draggingElement)) {
pointerDownState.drag.hasOccurred = true;
const points = draggingElement.points;