Procházet zdrojové kódy

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

Maurice Le Cordier před 4 roky
rodič
revize
d15444e232
1 změnil soubory, kde provedl 7 přidání a 2 odebrání
  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);