mirror of
https://github.com/excalidraw/excalidraw.git
synced 2025-02-18 13:29:36 +01:00
Automatically select last inserted element
This commit is contained in:
parent
c26d04e162
commit
2fa00f39fc
@ -219,6 +219,9 @@ function App() {
|
|||||||
id="canvas"
|
id="canvas"
|
||||||
width={window.innerWidth}
|
width={window.innerWidth}
|
||||||
height={window.innerHeight}
|
height={window.innerHeight}
|
||||||
|
onClick={e => {
|
||||||
|
console.log("click");
|
||||||
|
}}
|
||||||
onMouseDown={e => {
|
onMouseDown={e => {
|
||||||
const x = e.clientX - e.target.offsetLeft;
|
const x = e.clientX - e.target.offsetLeft;
|
||||||
const y = e.clientY - e.target.offsetTop;
|
const y = e.clientY - e.target.offsetTop;
|
||||||
@ -255,12 +258,14 @@ function App() {
|
|||||||
drawScene();
|
drawScene();
|
||||||
}}
|
}}
|
||||||
onMouseUp={e => {
|
onMouseUp={e => {
|
||||||
setDraggingElement(null);
|
|
||||||
if (elementType === "selection") {
|
if (elementType === "selection") {
|
||||||
// Remove actual selection element
|
// Remove actual selection element
|
||||||
elements.pop();
|
elements.pop();
|
||||||
setSelection(draggingElement);
|
setSelection(draggingElement);
|
||||||
|
} else {
|
||||||
|
draggingElement.isSelected = true;
|
||||||
}
|
}
|
||||||
|
setDraggingElement(null);
|
||||||
setElementType("selection");
|
setElementType("selection");
|
||||||
drawScene();
|
drawScene();
|
||||||
}}
|
}}
|
||||||
|
Loading…
Reference in New Issue
Block a user