ensure alt+drag duplicates all selected elems (#258)

This commit is contained in:
David Luzar 2020-01-08 18:09:02 +01:00 committed by Christopher Chedeau
parent 08b804ac63
commit 58ec6567ae

View File

@ -680,21 +680,15 @@ class App extends React.Component<{}, AppState> {
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(
...elements.reduce((duplicates, element) => {
if (element.isSelected) {
duplicates.push({ ...element });
element.isSelected = false;
}
return duplicates;
}, [] as typeof elements)
);
elements.push(element);
}
} else {
// If we don't click on anything, let's remove all the selected elements