mirror of
https://github.com/excalidraw/excalidraw.git
synced 2025-10-08 00:29:50 +02:00
fix: Size-based orbit jump-in
This commit is contained in:
@@ -22,7 +22,11 @@ import type { AppState } from "@excalidraw/excalidraw/types";
|
|||||||
|
|
||||||
import type { MapEntry, Mutable } from "@excalidraw/common/utility-types";
|
import type { MapEntry, Mutable } from "@excalidraw/common/utility-types";
|
||||||
|
|
||||||
import { getCenterForBounds, getElementBounds } from "./bounds";
|
import {
|
||||||
|
doBoundsIntersect,
|
||||||
|
getCenterForBounds,
|
||||||
|
getElementBounds,
|
||||||
|
} from "./bounds";
|
||||||
import {
|
import {
|
||||||
getAllHoveredElementAtPoint,
|
getAllHoveredElementAtPoint,
|
||||||
getHoveredElementForBinding,
|
getHoveredElementForBinding,
|
||||||
@@ -359,8 +363,8 @@ const bindingStrategyForNewSimpleArrowEndpointDragging = (
|
|||||||
element: hit,
|
element: hit,
|
||||||
focusPoint:
|
focusPoint:
|
||||||
isInsideBinding || isNested
|
isInsideBinding || isNested
|
||||||
? point
|
? point
|
||||||
: snapToCenter(hit, elementsMap, point),
|
: snapToCenter(hit, elementsMap, point),
|
||||||
};
|
};
|
||||||
} else {
|
} else {
|
||||||
current = { mode: null };
|
current = { mode: null };
|
||||||
@@ -414,11 +418,11 @@ const bindingStrategyForSimpleArrowEndpointDragging = (
|
|||||||
: false;
|
: false;
|
||||||
const oppositeElement = oppositeBinding
|
const oppositeElement = oppositeBinding
|
||||||
? (elementsMap.get(oppositeBinding.elementId) as ExcalidrawBindableElement)
|
? (elementsMap.get(oppositeBinding.elementId) as ExcalidrawBindableElement)
|
||||||
: null;
|
: null;
|
||||||
const otherIsTransparent =
|
const otherIsTransparent =
|
||||||
isOverlapping && oppositeElement
|
isOverlapping && oppositeElement
|
||||||
? isTransparent(oppositeElement.backgroundColor)
|
? isTransparent(oppositeElement.backgroundColor)
|
||||||
: false;
|
: false;
|
||||||
const isNested =
|
const isNested =
|
||||||
hit &&
|
hit &&
|
||||||
oppositeElement &&
|
oppositeElement &&
|
||||||
@@ -1223,6 +1227,11 @@ const snapToMid = (
|
|||||||
return p;
|
return p;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const compareElementArea = (
|
||||||
|
a: ExcalidrawBindableElement,
|
||||||
|
b: ExcalidrawBindableElement,
|
||||||
|
) => b.width ** 2 + b.height ** 2 - (a.width ** 2 + a.height ** 2);
|
||||||
|
|
||||||
export const updateBoundPoint = (
|
export const updateBoundPoint = (
|
||||||
arrow: NonDeleted<ExcalidrawArrowElement>,
|
arrow: NonDeleted<ExcalidrawArrowElement>,
|
||||||
startOrEnd: "startBinding" | "endBinding",
|
startOrEnd: "startBinding" | "endBinding",
|
||||||
@@ -1253,8 +1262,15 @@ export const updateBoundPoint = (
|
|||||||
otherBinding &&
|
otherBinding &&
|
||||||
(elementsMap.get(otherBinding.elementId)! as ExcalidrawBindableElement);
|
(elementsMap.get(otherBinding.elementId)! as ExcalidrawBindableElement);
|
||||||
const bounds = getElementBounds(bindableElement, elementsMap);
|
const bounds = getElementBounds(bindableElement, elementsMap);
|
||||||
const isNested =
|
const otherBounds =
|
||||||
otherBindableElement && isElementInsideBBox(otherBindableElement, bounds);
|
otherBindableElement && getElementBounds(otherBindableElement, elementsMap);
|
||||||
|
const isLargerThanOther =
|
||||||
|
otherBindableElement &&
|
||||||
|
compareElementArea(bindableElement, otherBindableElement) < 0;
|
||||||
|
const isIntersecting = otherBounds && doBoundsIntersect(bounds, otherBounds);
|
||||||
|
// const isNested =
|
||||||
|
// otherBindableElement && isElementInsideBBox(otherBindableElement, bounds);
|
||||||
|
const isNested = isIntersecting && isLargerThanOther;
|
||||||
|
|
||||||
const maybeOutlineGlobal =
|
const maybeOutlineGlobal =
|
||||||
binding.mode === "orbit" && bindableElement
|
binding.mode === "orbit" && bindableElement
|
||||||
|
Reference in New Issue
Block a user