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