UI move buttons (#99)
This commit is contained in:
parent
0d5272720f
commit
e9484080e7
@ -659,6 +659,9 @@ function getSelectedIndices() {
|
|||||||
return selectedIndices;
|
return selectedIndices;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const someElementIsSelected = () =>
|
||||||
|
elements.some(element => element.isSelected);
|
||||||
|
|
||||||
const ELEMENT_SHIFT_TRANSLATE_AMOUNT = 5;
|
const ELEMENT_SHIFT_TRANSLATE_AMOUNT = 5;
|
||||||
const ELEMENT_TRANSLATE_AMOUNT = 1;
|
const ELEMENT_TRANSLATE_AMOUNT = 1;
|
||||||
|
|
||||||
@ -730,14 +733,12 @@ class App extends React.Component<{}, AppState> {
|
|||||||
event.altKey &&
|
event.altKey &&
|
||||||
event.code === "KeyB"
|
event.code === "KeyB"
|
||||||
) {
|
) {
|
||||||
moveOneLeft(elements, getSelectedIndices());
|
this.moveOneLeft();
|
||||||
this.forceUpdate();
|
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
|
|
||||||
// Send to back: Cmd-Shift-B
|
// Send to back: Cmd-Shift-B
|
||||||
} else if (event.metaKey && event.shiftKey && event.code === "KeyB") {
|
} else if (event.metaKey && event.shiftKey && event.code === "KeyB") {
|
||||||
moveAllLeft(elements, getSelectedIndices());
|
this.moveAllLeft();
|
||||||
this.forceUpdate();
|
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
|
|
||||||
// Select all: Cmd-A
|
// Select all: Cmd-A
|
||||||
@ -752,6 +753,21 @@ class App extends React.Component<{}, AppState> {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
private deleteSelectedElements = () => {
|
||||||
|
deleteSelectedElements();
|
||||||
|
this.forceUpdate();
|
||||||
|
};
|
||||||
|
|
||||||
|
private moveAllLeft = () => {
|
||||||
|
moveAllLeft(elements, getSelectedIndices());
|
||||||
|
this.forceUpdate();
|
||||||
|
};
|
||||||
|
|
||||||
|
private moveOneLeft = () => {
|
||||||
|
moveOneLeft(elements, getSelectedIndices());
|
||||||
|
this.forceUpdate();
|
||||||
|
};
|
||||||
|
|
||||||
public render() {
|
public render() {
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
@ -896,6 +912,17 @@ class App extends React.Component<{}, AppState> {
|
|||||||
px)
|
px)
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
{someElementIsSelected() && (
|
||||||
|
<>
|
||||||
|
<h4>Shape options</h4>
|
||||||
|
<div className="panelColumn">
|
||||||
|
<button onClick={this.deleteSelectedElements}>Delete</button>
|
||||||
|
<button>Move to front</button>
|
||||||
|
<button onClick={this.moveOneLeft}>Send backwards</button>
|
||||||
|
<button onClick={this.moveAllLeft}>Send to back</button>
|
||||||
|
</div>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
<canvas
|
<canvas
|
||||||
id="canvas"
|
id="canvas"
|
||||||
@ -950,7 +977,7 @@ class App extends React.Component<{}, AppState> {
|
|||||||
clearSelection();
|
clearSelection();
|
||||||
}
|
}
|
||||||
|
|
||||||
isDraggingElements = elements.some(element => element.isSelected);
|
isDraggingElements = someElementIsSelected();
|
||||||
|
|
||||||
if (isDraggingElements) {
|
if (isDraggingElements) {
|
||||||
document.documentElement.style.cursor = "move";
|
document.documentElement.style.cursor = "move";
|
||||||
|
Loading…
x
Reference in New Issue
Block a user