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

This commit is contained in:
Maurice Le Cordier 2020-08-29 20:01:36 +02:00 committed by GitHub
parent 7ebeae2d38
commit d15444e232
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1000,13 +1000,18 @@ class App extends React.Component<ExcalidrawProps, AppState> {
const oldIdToDuplicatedId = new Map(); const oldIdToDuplicatedId = new Map();
const newElements = clipboardElements.map((element) => { const newElements = clipboardElements.map((element) => {
const [pastedPositionX, pastedPositionY] = getGridPoint(
element.x + dx - minX,
element.y + dy - minY,
this.state.gridSize,
);
const newElement = duplicateElement( const newElement = duplicateElement(
this.state.editingGroupId, this.state.editingGroupId,
groupIdMap, groupIdMap,
element, element,
{ {
x: element.x + dx - minX, x: pastedPositionX,
y: element.y + dy - minY, y: pastedPositionY,
}, },
); );
oldIdToDuplicatedId.set(element.id, newElement.id); oldIdToDuplicatedId.set(element.id, newElement.id);