mirror of
https://github.com/excalidraw/excalidraw.git
synced 2025-10-14 19:50:37 +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);
|
origElements.push(origElement);
|
||||||
}
|
}
|
||||||
|
|
||||||
const adjustedOffset = calculateOffset(
|
const adjustedOffset = calculateDragOffset(
|
||||||
getCommonBounds(origElements),
|
getCommonBounds(origElements),
|
||||||
offset,
|
offset,
|
||||||
snapOffset,
|
snapOffset,
|
||||||
@@ -125,7 +125,7 @@ export const dragSelectedElements = (
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
const calculateOffset = (
|
export const calculateDragOffset = (
|
||||||
commonBounds: Bounds,
|
commonBounds: Bounds,
|
||||||
dragOffset: { x: number; y: number },
|
dragOffset: { x: number; y: number },
|
||||||
snapOffset: { x: number; y: number },
|
snapOffset: { x: number; y: number },
|
||||||
|
@@ -240,6 +240,7 @@ import {
|
|||||||
StoreDelta,
|
StoreDelta,
|
||||||
type ApplyToOptions,
|
type ApplyToOptions,
|
||||||
positionElementsOnGrid,
|
positionElementsOnGrid,
|
||||||
|
calculateDragOffset,
|
||||||
} from "@excalidraw/element";
|
} from "@excalidraw/element";
|
||||||
|
|
||||||
import type { LocalPoint, Radians } from "@excalidraw/math";
|
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) => {
|
const mappedClonedElements = elementsWithDuplicates.map((el) => {
|
||||||
if (idsOfElementsToDuplicate.has(el.id)) {
|
if (idsOfElementsToDuplicate.has(el.id)) {
|
||||||
const origEl = pointerDownState.originalElements.get(el.id);
|
const origEl = pointerDownState.originalElements.get(el.id);
|
||||||
|
|
||||||
if (origEl) {
|
if (origEl) {
|
||||||
return newElementWith(el, {
|
return newElementWith(el, {
|
||||||
x: origEl.x,
|
x: origEl.x + diffX,
|
||||||
y: origEl.y,
|
y: origEl.y + diffY,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user