mirror of
https://github.com/excalidraw/excalidraw.git
synced 2025-11-15 10:15:03 +01:00
fix: Preserve alternate orbit focus point during drag
This commit is contained in:
@@ -410,7 +410,9 @@ export class LinearElementEditor {
|
|||||||
initialState: {
|
initialState: {
|
||||||
...linearElementEditor.initialState,
|
...linearElementEditor.initialState,
|
||||||
altFocusPoint:
|
altFocusPoint:
|
||||||
!linearElementEditor.initialState.altFocusPoint && startBindingElement
|
!linearElementEditor.initialState.altFocusPoint &&
|
||||||
|
startBindingElement &&
|
||||||
|
updates?.suggestedBinding?.id !== startBindingElement.id
|
||||||
? projectFixedPointOntoDiagonal(
|
? projectFixedPointOntoDiagonal(
|
||||||
element,
|
element,
|
||||||
pointFrom<GlobalPoint>(element.x, element.y),
|
pointFrom<GlobalPoint>(element.x, element.y),
|
||||||
@@ -610,6 +612,22 @@ export class LinearElementEditor {
|
|||||||
(elementsMap.get(
|
(elementsMap.get(
|
||||||
element.startBinding.elementId,
|
element.startBinding.elementId,
|
||||||
) as ExcalidrawBindableElement | null);
|
) as ExcalidrawBindableElement | null);
|
||||||
|
const endBindingElement =
|
||||||
|
isBindingElement(element) &&
|
||||||
|
element.endBinding &&
|
||||||
|
(elementsMap.get(
|
||||||
|
element.endBinding.elementId,
|
||||||
|
) as ExcalidrawBindableElement | null);
|
||||||
|
const altFocusPointBindableElement =
|
||||||
|
endIsSelected && // The "other" end (i.e. "end") is dragged
|
||||||
|
startBindingElement &&
|
||||||
|
updates?.suggestedBinding?.id !== startBindingElement.id // The end point is not hovering the start bindable + it's binding gap
|
||||||
|
? startBindingElement
|
||||||
|
: startIsSelected && // The "other" end (i.e. "start") is dragged
|
||||||
|
endBindingElement &&
|
||||||
|
updates?.suggestedBinding?.id !== endBindingElement.id // The start point is not hovering the end bindable + it's binding gap
|
||||||
|
? endBindingElement
|
||||||
|
: null;
|
||||||
|
|
||||||
const newLinearElementEditor = {
|
const newLinearElementEditor = {
|
||||||
...linearElementEditor,
|
...linearElementEditor,
|
||||||
@@ -618,11 +636,13 @@ export class LinearElementEditor {
|
|||||||
...linearElementEditor.initialState,
|
...linearElementEditor.initialState,
|
||||||
lastClickedPoint: newLastClickedPoint,
|
lastClickedPoint: newLastClickedPoint,
|
||||||
altFocusPoint:
|
altFocusPoint:
|
||||||
!linearElementEditor.initialState.altFocusPoint && startBindingElement
|
!linearElementEditor.initialState.altFocusPoint && // We only set it once per arrow drag
|
||||||
|
isBindingElement(element) &&
|
||||||
|
altFocusPointBindableElement
|
||||||
? projectFixedPointOntoDiagonal(
|
? projectFixedPointOntoDiagonal(
|
||||||
element,
|
element,
|
||||||
pointFrom<GlobalPoint>(element.x, element.y),
|
pointFrom<GlobalPoint>(element.x, element.y),
|
||||||
startBindingElement,
|
altFocusPointBindableElement,
|
||||||
"start",
|
"start",
|
||||||
elementsMap,
|
elementsMap,
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import {
|
import {
|
||||||
|
debugDrawLine,
|
||||||
DEFAULT_ADAPTIVE_RADIUS,
|
DEFAULT_ADAPTIVE_RADIUS,
|
||||||
DEFAULT_PROPORTIONAL_RADIUS,
|
DEFAULT_PROPORTIONAL_RADIUS,
|
||||||
invariant,
|
invariant,
|
||||||
@@ -598,9 +599,9 @@ export const projectFixedPointOntoDiagonal = (
|
|||||||
p = p1 || p2 || null;
|
p = p1 || p2 || null;
|
||||||
}
|
}
|
||||||
|
|
||||||
// debugDrawLine(diagonalOne, { color: "purple", permanent: true });
|
debugDrawLine(diagonalOne, { color: "purple", permanent: false });
|
||||||
// debugDrawLine(diagonalTwo, { color: "purple", permanent: true });
|
debugDrawLine(diagonalTwo, { color: "purple", permanent: false });
|
||||||
// debugDrawLine(intersector, { color: "orange", permanent: true });
|
debugDrawLine(intersector, { color: "orange", permanent: false });
|
||||||
|
|
||||||
return p && isPointInElement(p, element, elementsMap) ? p : null;
|
return p && isPointInElement(p, element, elementsMap) ? p : null;
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user