also sort during resize
This commit is contained in:
parent
328b641533
commit
145e61c607
1 changed files with 8 additions and 10 deletions
|
|
@ -85,16 +85,6 @@ export function VisualEditor() {
|
||||||
|
|
||||||
const refSVG = useRef<SVGSVGElement>(null);
|
const refSVG = useRef<SVGSVGElement>(null);
|
||||||
|
|
||||||
// useEffect(() => {
|
|
||||||
// console.log('selection:', selection);
|
|
||||||
// }, [selection]);
|
|
||||||
// useEffect(() => {
|
|
||||||
// console.log('state:', state);
|
|
||||||
// }, [state]);
|
|
||||||
// useEffect(() => {
|
|
||||||
// console.log('selectingState:', selectingState);
|
|
||||||
// }, [selectingState]);
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const recoveredState = JSON.parse(window.localStorage.getItem("state") || "null") || emptyState;
|
const recoveredState = JSON.parse(window.localStorage.getItem("state") || "null") || emptyState;
|
||||||
setState(recoveredState);
|
setState(recoveredState);
|
||||||
|
|
@ -211,6 +201,13 @@ export function VisualEditor() {
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// sort: smaller rountangles are drawn on top
|
||||||
|
setState(state => ({
|
||||||
|
...state,
|
||||||
|
rountangles: state.rountangles.toSorted((a,b) => area(b) - area(a)),
|
||||||
|
}));
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const onMouseUp = (e: MouseEvent) => {
|
const onMouseUp = (e: MouseEvent) => {
|
||||||
|
|
@ -247,6 +244,7 @@ export function VisualEditor() {
|
||||||
}
|
}
|
||||||
return null; // no longer selecting
|
return null; // no longer selecting
|
||||||
});
|
});
|
||||||
|
|
||||||
// sort: smaller rountangles are drawn on top
|
// sort: smaller rountangles are drawn on top
|
||||||
setState(state => ({
|
setState(state => ({
|
||||||
...state,
|
...state,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue