don't allow dragging hidden points
This commit is contained in:
parent
8971d06655
commit
cd195374bc
@ -3084,7 +3084,7 @@ class App extends React.Component<AppProps, AppState> {
|
|||||||
])
|
])
|
||||||
) {
|
) {
|
||||||
hoverPointIndex = LinearElementEditor.getPointIndexUnderCursor(
|
hoverPointIndex = LinearElementEditor.getPointIndexUnderCursor(
|
||||||
element,
|
this.state.selectedLinearElement,
|
||||||
this.state.zoom,
|
this.state.zoom,
|
||||||
scenePointerX,
|
scenePointerX,
|
||||||
scenePointerY,
|
scenePointerY,
|
||||||
|
@ -380,7 +380,7 @@ export class LinearElementEditor {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
const clickedPointIndex = LinearElementEditor.getPointIndexUnderCursor(
|
const clickedPointIndex = LinearElementEditor.getPointIndexUnderCursor(
|
||||||
element,
|
appState.selectedLinearElement,
|
||||||
appState.zoom,
|
appState.zoom,
|
||||||
scenePointer.x,
|
scenePointer.x,
|
||||||
scenePointer.y,
|
scenePointer.y,
|
||||||
@ -566,7 +566,7 @@ export class LinearElementEditor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const clickedPointIndex = LinearElementEditor.getPointIndexUnderCursor(
|
const clickedPointIndex = LinearElementEditor.getPointIndexUnderCursor(
|
||||||
element,
|
appState.selectedLinearElement,
|
||||||
appState.zoom,
|
appState.zoom,
|
||||||
scenePointer.x,
|
scenePointer.x,
|
||||||
scenePointer.y,
|
scenePointer.y,
|
||||||
@ -773,19 +773,30 @@ export class LinearElementEditor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static getPointIndexUnderCursor(
|
static getPointIndexUnderCursor(
|
||||||
element: NonDeleted<ExcalidrawLinearElement>,
|
linearElementEditor: LinearElementEditor | null,
|
||||||
zoom: AppState["zoom"],
|
zoom: AppState["zoom"],
|
||||||
x: number,
|
x: number,
|
||||||
y: number,
|
y: number,
|
||||||
) {
|
) {
|
||||||
|
if (!linearElementEditor) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
const element = LinearElementEditor.getElement(
|
||||||
|
linearElementEditor.elementId,
|
||||||
|
);
|
||||||
|
if (!element) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
const pointHandles =
|
const pointHandles =
|
||||||
LinearElementEditor.getPointsGlobalCoordinates(element);
|
LinearElementEditor.getPointsGlobalCoordinates(element);
|
||||||
let idx = pointHandles.length;
|
let idx = linearElementEditor.visiblePointIndexes.length;
|
||||||
|
|
||||||
// loop from right to left because points on the right are rendered over
|
// loop from right to left because points on the right are rendered over
|
||||||
// points on the left, thus should take precedence when clicking, if they
|
// points on the left, thus should take precedence when clicking, if they
|
||||||
// overlap
|
// overlap
|
||||||
while (--idx > -1) {
|
while (--idx > 0) {
|
||||||
const point = pointHandles[idx];
|
const point = pointHandles[linearElementEditor.visiblePointIndexes[idx]];
|
||||||
if (
|
if (
|
||||||
distance2d(x, y, point[0], point[1]) * zoom.value <
|
distance2d(x, y, point[0], point[1]) * zoom.value <
|
||||||
// +1px to account for outline stroke
|
// +1px to account for outline stroke
|
||||||
|
Loading…
x
Reference in New Issue
Block a user