mirror of
https://github.com/excalidraw/excalidraw.git
synced 2025-11-11 08:14:17 +01:00
fix: Preserve alternate orbit focus point during drag
This commit is contained in:
@@ -410,7 +410,9 @@ export class LinearElementEditor {
|
||||
initialState: {
|
||||
...linearElementEditor.initialState,
|
||||
altFocusPoint:
|
||||
!linearElementEditor.initialState.altFocusPoint && startBindingElement
|
||||
!linearElementEditor.initialState.altFocusPoint &&
|
||||
startBindingElement &&
|
||||
updates?.suggestedBinding?.id !== startBindingElement.id
|
||||
? projectFixedPointOntoDiagonal(
|
||||
element,
|
||||
pointFrom<GlobalPoint>(element.x, element.y),
|
||||
@@ -610,6 +612,22 @@ export class LinearElementEditor {
|
||||
(elementsMap.get(
|
||||
element.startBinding.elementId,
|
||||
) 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 = {
|
||||
...linearElementEditor,
|
||||
@@ -618,11 +636,13 @@ export class LinearElementEditor {
|
||||
...linearElementEditor.initialState,
|
||||
lastClickedPoint: newLastClickedPoint,
|
||||
altFocusPoint:
|
||||
!linearElementEditor.initialState.altFocusPoint && startBindingElement
|
||||
!linearElementEditor.initialState.altFocusPoint && // We only set it once per arrow drag
|
||||
isBindingElement(element) &&
|
||||
altFocusPointBindableElement
|
||||
? projectFixedPointOntoDiagonal(
|
||||
element,
|
||||
pointFrom<GlobalPoint>(element.x, element.y),
|
||||
startBindingElement,
|
||||
altFocusPointBindableElement,
|
||||
"start",
|
||||
elementsMap,
|
||||
)
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import {
|
||||
debugDrawLine,
|
||||
DEFAULT_ADAPTIVE_RADIUS,
|
||||
DEFAULT_PROPORTIONAL_RADIUS,
|
||||
invariant,
|
||||
@@ -598,9 +599,9 @@ export const projectFixedPointOntoDiagonal = (
|
||||
p = p1 || p2 || null;
|
||||
}
|
||||
|
||||
// debugDrawLine(diagonalOne, { color: "purple", permanent: true });
|
||||
// debugDrawLine(diagonalTwo, { color: "purple", permanent: true });
|
||||
// debugDrawLine(intersector, { color: "orange", permanent: true });
|
||||
debugDrawLine(diagonalOne, { color: "purple", permanent: false });
|
||||
debugDrawLine(diagonalTwo, { color: "purple", permanent: false });
|
||||
debugDrawLine(intersector, { color: "orange", permanent: false });
|
||||
|
||||
return p && isPointInElement(p, element, elementsMap) ? p : null;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user