From 4672a2a135a81d21d98bc906d2273af8096019d6 Mon Sep 17 00:00:00 2001 From: David Luzar Date: Wed, 9 Dec 2020 14:45:03 +0100 Subject: [PATCH] fix misaligning on grid paste (#2494) * fix misaligning on grid paste * tweak naming --- src/components/App.tsx | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/components/App.tsx b/src/components/App.tsx index e6b39983..cd927037 100644 --- a/src/components/App.tsx +++ b/src/components/App.tsx @@ -1021,20 +1021,17 @@ class App extends React.Component { const dy = y - elementsCenterY; const groupIdMap = new Map(); + const [gridX, gridY] = getGridPoint(dx, dy, this.state.gridSize); + const oldIdToDuplicatedId = new Map(); const newElements = clipboardElements.map((element) => { - const [pastedPositionX, pastedPositionY] = getGridPoint( - element.x + dx - minX, - element.y + dy - minY, - this.state.gridSize, - ); const newElement = duplicateElement( this.state.editingGroupId, groupIdMap, element, { - x: pastedPositionX, - y: pastedPositionY, + x: element.x + gridX - minX, + y: element.y + gridY - minY, }, ); oldIdToDuplicatedId.set(element.id, newElement.id);