fix: Alt-duplication doesn't place the duplicate at the last moment where Alt is pressed

fix: Shift + Alt
This commit is contained in:
Mark Tolmacs
2025-10-11 14:16:51 +02:00
parent 19b03b4ca9
commit 20eaddee92
2 changed files with 11 additions and 4 deletions

View File

@@ -95,7 +95,7 @@ export const dragSelectedElements = (
origElements.push(origElement);
}
const adjustedOffset = calculateOffset(
const adjustedOffset = calculateDragOffset(
getCommonBounds(origElements),
offset,
snapOffset,
@@ -125,7 +125,7 @@ export const dragSelectedElements = (
});
};
const calculateOffset = (
export const calculateDragOffset = (
commonBounds: Bounds,
dragOffset: { x: number; y: number },
snapOffset: { x: number; y: number },

View File

@@ -240,6 +240,7 @@ import {
StoreDelta,
type ApplyToOptions,
positionElementsOnGrid,
calculateDragOffset,
} from "@excalidraw/element";
import type { LocalPoint, Radians } from "@excalidraw/math";
@@ -8782,14 +8783,20 @@ class App extends React.Component<AppProps, AppState> {
);
});
const { x: diffX, y: diffY } = calculateDragOffset(
getCommonBounds(elementsWithDuplicates),
dragOffset,
snapOffset,
event[KEYS.CTRL_OR_CMD] ? null : this.getEffectiveGridSize(),
);
const mappedClonedElements = elementsWithDuplicates.map((el) => {
if (idsOfElementsToDuplicate.has(el.id)) {
const origEl = pointerDownState.originalElements.get(el.id);
if (origEl) {
return newElementWith(el, {
x: origEl.x,
y: origEl.y,
x: origEl.x + diffX,
y: origEl.y + diffY,
});
}
}