Skip to content

Commit

Permalink
fix: freedraw slow movement jittery lines (excalidraw#4726)
Browse files Browse the repository at this point in the history
Co-authored-by: David Luzar <[email protected]>
  • Loading branch information
zsviczian and dwelle authored Feb 6, 2022
1 parent 98ea466 commit 96de887
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions src/components/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 96de887

Please sign in to comment.