mirror of
https://github.com/excalidraw/excalidraw.git
synced 2025-10-12 18:49:55 +02:00
fix: Alt-duplication doesn't place the duplicate at the last moment where Alt is pressed
fix: Shift + Alt
This commit is contained in:
@@ -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 },
|
||||
|
@@ -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,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user