From d15444e232943173c368494a1b3f11bbf84b4b1d Mon Sep 17 00:00:00 2001 From: Maurice Le Cordier Date: Sat, 29 Aug 2020 20:01:36 +0200 Subject: [PATCH] allowed for sticking to grid when pasting an element (#2107) --- src/components/App.tsx | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/components/App.tsx b/src/components/App.tsx index 3d53a85a..a3713002 100644 --- a/src/components/App.tsx +++ b/src/components/App.tsx @@ -1000,13 +1000,18 @@ class App extends React.Component { 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: element.x + dx - minX, - y: element.y + dy - minY, + x: pastedPositionX, + y: pastedPositionY, }, ); oldIdToDuplicatedId.set(element.id, newElement.id);