fix misaligning on grid paste (#2494)

* fix misaligning on grid paste

* tweak naming
This commit is contained in:
David Luzar 2020-12-09 14:45:03 +01:00 committed by GitHub
parent c7b5cdb71e
commit 4672a2a135
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1021,20 +1021,17 @@ class App extends React.Component<ExcalidrawProps, AppState> {
const dy = y - elementsCenterY; const dy = y - elementsCenterY;
const groupIdMap = new Map(); const groupIdMap = new Map();
const [gridX, gridY] = getGridPoint(dx, dy, this.state.gridSize);
const oldIdToDuplicatedId = new Map(); const oldIdToDuplicatedId = new Map();
const newElements = clipboardElements.map((element) => { const newElements = clipboardElements.map((element) => {
const [pastedPositionX, pastedPositionY] = getGridPoint(
element.x + dx - minX,
element.y + dy - minY,
this.state.gridSize,
);
const newElement = duplicateElement( const newElement = duplicateElement(
this.state.editingGroupId, this.state.editingGroupId,
groupIdMap, groupIdMap,
element, element,
{ {
x: pastedPositionX, x: element.x + gridX - minX,
y: pastedPositionY, y: element.y + gridY - minY,
}, },
); );
oldIdToDuplicatedId.set(element.id, newElement.id); oldIdToDuplicatedId.set(element.id, newElement.id);