Browse Source

allowed for sticking to grid when pasting an element (#2107)

Maurice Le Cordier 4 years ago
parent
commit
d15444e232
1 changed files with 7 additions and 2 deletions
  1. 7 2
      src/components/App.tsx

+ 7 - 2
src/components/App.tsx

@@ -1000,13 +1000,18 @@ class App extends React.Component<ExcalidrawProps, AppState> {
 
     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);