From 0fee1579e2d6627189d36509bcbda1487bab9e8c Mon Sep 17 00:00:00 2001 From: Faustino Kialungila Date: Tue, 7 Jan 2020 19:49:12 +0100 Subject: [PATCH] Center element on paste --- src/index.tsx | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/index.tsx b/src/index.tsx index c24997855..f41b3104b 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -1009,9 +1009,8 @@ class App extends React.Component<{}, AppState> { parsedElements[0].type // need to implement a better check here... ) { clearSelection(elements); - - if (x == null) x = 10 - this.state.scrollX; - if (y == null) y = 10 - this.state.scrollY; + if (x == null) x = window.innerWidth / 2 - this.state.scrollX - 10; + if (y == null) y = window.innerHeight / 2 - this.state.scrollY - 10; const minX = Math.min(...parsedElements.map(element => element.x)); const minY = Math.min(...parsedElements.map(element => element.y)); const dx = x - minX;