소스 검색

duplicate element by alt dragging (#255)

Jeremy Scatigna 5 년 전
부모
커밋
e7bf034fef
1개의 변경된 파일20개의 추가작업 그리고 2개의 파일을 삭제
  1. 20 2
      src/index.tsx

+ 20 - 2
src/index.tsx

@@ -675,8 +675,26 @@ class App extends React.Component<{}, AppState> {
                     if (!e.shiftKey) {
                       clearSelection(elements);
                     }
-                    // No matter what, we select it
-                    hitElement.isSelected = true;
+                  }
+                  // No matter what, we select it
+                  hitElement.isSelected = true;
+                  // We duplicate the selected element if alt is pressed on Mouse down
+                  if (e.altKey) {
+                    const element = newElement(
+                      hitElement.type,
+                      hitElement.x,
+                      hitElement.y,
+                      hitElement.strokeColor,
+                      hitElement.backgroundColor,
+                      hitElement.fillStyle,
+                      hitElement.strokeWidth,
+                      hitElement.roughness,
+                      hitElement.opacity,
+                      hitElement.width,
+                      hitElement.height
+                    );
+
+                    elements.push(element);
                   }
                 } else {
                   // If we don't click on anything, let's remove all the selected elements