mirror of
https://github.com/excalidraw/excalidraw.git
synced 2025-05-03 10:00:07 -04:00
Center element on paste
This commit is contained in:
parent
2f9aa0e3ca
commit
0fee1579e2
1 changed files with 2 additions and 3 deletions
|
@ -1009,9 +1009,8 @@ class App extends React.Component<{}, AppState> {
|
||||||
parsedElements[0].type // need to implement a better check here...
|
parsedElements[0].type // need to implement a better check here...
|
||||||
) {
|
) {
|
||||||
clearSelection(elements);
|
clearSelection(elements);
|
||||||
|
if (x == null) x = window.innerWidth / 2 - this.state.scrollX - 10;
|
||||||
if (x == null) x = 10 - this.state.scrollX;
|
if (y == null) y = window.innerHeight / 2 - this.state.scrollY - 10;
|
||||||
if (y == null) y = 10 - this.state.scrollY;
|
|
||||||
const minX = Math.min(...parsedElements.map(element => element.x));
|
const minX = Math.min(...parsedElements.map(element => element.x));
|
||||||
const minY = Math.min(...parsedElements.map(element => element.y));
|
const minY = Math.min(...parsedElements.map(element => element.y));
|
||||||
const dx = x - minX;
|
const dx = x - minX;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue