Fix linear editor bug when both midpoint and endpoint is moved

This commit is contained in:
Mark Tolmacs 2025-06-24 18:26:17 +02:00
parent 8c2de8c3c4
commit 4980631cb1
No known key found for this signature in database

View File

@ -1475,7 +1475,8 @@ export class LinearElementEditor {
if (
otherUpdates?.moveMidPointsWithElement &&
idx !== 0 &&
idx !== points.length - 1
idx !== points.length - 1 &&
!pointUpdates.has(idx)
) {
return pointFrom<LocalPoint>(current[0], current[1]);
}
@ -2023,6 +2024,11 @@ const pointDraggingUpdates = (
elements: readonly Ordered<NonDeletedExcalidrawElement>[],
zoom: AppState["zoom"],
): PointsPositionUpdates => {
const hasMidPoints =
selectedPointsIndices.filter(
(_, idx) => idx > 0 && idx < element.points.length - 1,
).length > 0;
return new Map(
selectedPointsIndices.map((pointIndex) => {
let newPointPosition: LocalPoint =
@ -2039,7 +2045,10 @@ const pointDraggingUpdates = (
element.points[pointIndex][1] + deltaY,
);
if (pointIndex === 0 || pointIndex === element.points.length - 1) {
if (
!hasMidPoints &&
(pointIndex === 0 || pointIndex === element.points.length - 1)
) {
const [, , , , cx, cy] = getElementAbsoluteCoords(
element,
elementsMap,