浏览代码

perf: Improve elbow arrow indirect binding logic (#9624)

Márk Tolmács 3 月之前
父节点
当前提交
f42e1ab64e
共有 2 个文件被更改,包括 5 次插入16 次删除
  1. 4 11
      packages/element/src/elbowArrow.ts
  2. 1 5
      packages/element/src/resizeElements.ts

+ 4 - 11
packages/element/src/elbowArrow.ts

@@ -20,6 +20,7 @@ import {
   tupleToCoors,
   getSizeFromPoints,
   isDevEnv,
+  arrayToMap,
 } from "@excalidraw/common";
 
 import type { AppState } from "@excalidraw/excalidraw/types";
@@ -2208,20 +2209,12 @@ const getGlobalPoint = (
     return initialPoint;
   }
 
-  if (element && elementsMap) {
-    const fixedGlobalPoint = getGlobalFixedPointForBindableElement(
+  if (element) {
+    return getGlobalFixedPointForBindableElement(
       fixedPointRatio || [0, 0],
       element,
-      elementsMap,
+      elementsMap ?? arrayToMap([element]),
     );
-
-    // NOTE: Resize scales the binding position point too, so we need to update it
-    return Math.abs(
-      distanceToElement(element, elementsMap, fixedGlobalPoint) -
-        FIXED_BINDING_DISTANCE,
-    ) > 0.01
-      ? bindPointToSnapToElementOutline(arrow, element, startOrEnd, elementsMap)
-      : fixedGlobalPoint;
   }
 
   return initialPoint;

+ 1 - 5
packages/element/src/resizeElements.ts

@@ -1518,11 +1518,7 @@ export const resizeMultipleElements = (
     } of elementsAndUpdates) {
       const { width, height, angle } = update;
 
-      scene.mutateElement(element, update, {
-        informMutation: true,
-        // needed for the fixed binding point udpate to take effect
-        isDragging: true,
-      });
+      scene.mutateElement(element, update);
 
       updateBoundElements(element, scene, {
         simultaneouslyUpdated: elementsToUpdate,