don't update points unitil deselected
This commit is contained in:
parent
3487f0ab26
commit
9b5715623a
@ -33,6 +33,9 @@ export const actionFinalize = register({
|
||||
endBindingElement,
|
||||
);
|
||||
}
|
||||
const selectedLinearElement = appState.selectedLinearElement
|
||||
? new LinearElementEditor(element, scene)
|
||||
: null;
|
||||
return {
|
||||
elements:
|
||||
element.points.length < 2 || isInvisiblySmallElement(element)
|
||||
@ -42,6 +45,7 @@ export const actionFinalize = register({
|
||||
...appState,
|
||||
cursorButton: "up",
|
||||
editingLinearElement: null,
|
||||
selectedLinearElement,
|
||||
},
|
||||
commitToHistory: true,
|
||||
};
|
||||
|
@ -1907,6 +1907,7 @@ class App extends React.Component<AppProps, AppState> {
|
||||
editingLinearElement: new LinearElementEditor(
|
||||
selectedElements[0],
|
||||
this.scene,
|
||||
true,
|
||||
),
|
||||
});
|
||||
}
|
||||
@ -2485,6 +2486,7 @@ class App extends React.Component<AppProps, AppState> {
|
||||
editingLinearElement: new LinearElementEditor(
|
||||
selectedElements[0],
|
||||
this.scene,
|
||||
true,
|
||||
),
|
||||
});
|
||||
}
|
||||
|
@ -53,8 +53,12 @@ export class LinearElementEditor {
|
||||
public readonly endBindingElement: ExcalidrawBindableElement | null | "keep";
|
||||
public readonly hoverPointIndex: number;
|
||||
public readonly midPointHovered: boolean;
|
||||
|
||||
constructor(element: NonDeleted<ExcalidrawLinearElement>, scene: Scene) {
|
||||
public readonly visiblePointIndexes: readonly number[];
|
||||
constructor(
|
||||
element: NonDeleted<ExcalidrawLinearElement>,
|
||||
scene: Scene,
|
||||
editingLinearElement = false,
|
||||
) {
|
||||
this.elementId = element.id as string & {
|
||||
_brand: "excalidrawLinearElementId";
|
||||
};
|
||||
@ -73,6 +77,10 @@ export class LinearElementEditor {
|
||||
};
|
||||
this.hoverPointIndex = -1;
|
||||
this.midPointHovered = false;
|
||||
this.visiblePointIndexes = LinearElementEditor.getVisiblePointIndexes(
|
||||
element,
|
||||
editingLinearElement,
|
||||
);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
@ -410,11 +418,9 @@ export class LinearElementEditor {
|
||||
}
|
||||
|
||||
static getVisiblePointIndexes(
|
||||
linearElementEditor: LinearElementEditor,
|
||||
appState: AppState,
|
||||
element: NonDeleted<ExcalidrawLinearElement>,
|
||||
editingLinearElement: boolean,
|
||||
) {
|
||||
const { elementId } = linearElementEditor;
|
||||
const element = LinearElementEditor.getElement(elementId);
|
||||
if (!element) {
|
||||
return [];
|
||||
}
|
||||
@ -432,7 +438,7 @@ export class LinearElementEditor {
|
||||
}
|
||||
const isExtremePoint = index === 0 || index === element.points.length - 1;
|
||||
if (
|
||||
appState.editingLinearElement ||
|
||||
editingLinearElement ||
|
||||
isExtremePoint ||
|
||||
distance >= 2 * LinearElementEditor.POINT_HANDLE_SIZE
|
||||
) {
|
||||
|
@ -165,6 +165,9 @@ const renderSingleLinearPoint = (
|
||||
isSelected: boolean,
|
||||
isPhantomPoint = false,
|
||||
) => {
|
||||
if (!point) {
|
||||
return;
|
||||
}
|
||||
context.strokeStyle = "#5e5ad8";
|
||||
context.setLineDash([]);
|
||||
context.fillStyle = "rgba(255, 255, 255, 0.9)";
|
||||
@ -207,10 +210,9 @@ const renderLinearPointHandles = (
|
||||
? POINT_HANDLE_SIZE
|
||||
: POINT_HANDLE_SIZE / 2;
|
||||
|
||||
const visiblePointIndexes = LinearElementEditor.getVisiblePointIndexes(
|
||||
appState.selectedLinearElement,
|
||||
appState,
|
||||
);
|
||||
const visiblePointIndexes =
|
||||
appState.editingLinearElement?.visiblePointIndexes ||
|
||||
appState.selectedLinearElement.visiblePointIndexes;
|
||||
visiblePointIndexes.forEach((index) => {
|
||||
const isSelected =
|
||||
!!appState.editingLinearElement?.selectedPointsIndices?.includes(index);
|
||||
@ -436,10 +438,9 @@ export const _renderScene = ({
|
||||
appState.selectedLinearElement &&
|
||||
appState.selectedLinearElement.hoverPointIndex >= 0
|
||||
) {
|
||||
const visiblePointIndexes = LinearElementEditor.getVisiblePointIndexes(
|
||||
appState.selectedLinearElement,
|
||||
appState,
|
||||
);
|
||||
const visiblePointIndexes =
|
||||
appState.editingLinearElement?.visiblePointIndexes ||
|
||||
appState.selectedLinearElement.visiblePointIndexes;
|
||||
if (
|
||||
visiblePointIndexes.includes(
|
||||
appState.selectedLinearElement.hoverPointIndex,
|
||||
|
@ -10993,6 +10993,10 @@ Object {
|
||||
},
|
||||
"selectedPointsIndices": null,
|
||||
"startBindingElement": "keep",
|
||||
"visiblePointIndexes": Array [
|
||||
0,
|
||||
1,
|
||||
],
|
||||
},
|
||||
"selectionElement": null,
|
||||
"shouldCacheIgnoreZoom": false,
|
||||
@ -11219,6 +11223,10 @@ Object {
|
||||
},
|
||||
"selectedPointsIndices": null,
|
||||
"startBindingElement": "keep",
|
||||
"visiblePointIndexes": Array [
|
||||
0,
|
||||
1,
|
||||
],
|
||||
},
|
||||
"selectionElement": null,
|
||||
"shouldCacheIgnoreZoom": false,
|
||||
@ -11672,6 +11680,10 @@ Object {
|
||||
},
|
||||
"selectedPointsIndices": null,
|
||||
"startBindingElement": "keep",
|
||||
"visiblePointIndexes": Array [
|
||||
0,
|
||||
1,
|
||||
],
|
||||
},
|
||||
"selectionElement": null,
|
||||
"shouldCacheIgnoreZoom": false,
|
||||
@ -12077,6 +12089,10 @@ Object {
|
||||
},
|
||||
"selectedPointsIndices": null,
|
||||
"startBindingElement": "keep",
|
||||
"visiblePointIndexes": Array [
|
||||
0,
|
||||
1,
|
||||
],
|
||||
},
|
||||
"selectionElement": null,
|
||||
"shouldCacheIgnoreZoom": false,
|
||||
|
Loading…
x
Reference in New Issue
Block a user