Ver Fonte

duplicate element by alt dragging (#255)

Jeremy Scatigna há 5 anos atrás
pai
commit
e7bf034fef
1 ficheiros alterados com 20 adições e 2 exclusões
  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