浏览代码

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

Maurice Le Cordier 4 年之前
父节点
当前提交
d15444e232
共有 1 个文件被更改,包括 7 次插入2 次删除
  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);