From e7bf034feffc7654f6fb315be76db58b3c20f41d Mon Sep 17 00:00:00 2001 From: Jeremy Scatigna Date: Wed, 8 Jan 2020 17:03:13 +0100 Subject: [PATCH] duplicate element by alt dragging (#255) --- src/index.tsx | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/src/index.tsx b/src/index.tsx index c2499785..1bc497c2 100644 --- a/src/index.tsx +++ b/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