瀏覽代碼

[skip ci] Binding refactor

Mark Tolmacs 5 月之前
父節點
當前提交
ce10087edc
共有 1 個文件被更改,包括 9 次插入19 次删除
  1. 9 19
      packages/element/src/binding.ts

+ 9 - 19
packages/element/src/binding.ts

@@ -223,13 +223,17 @@ const bindOrUnbindLinearElementEdge = (
   }
 };
 
-const getOriginalBindingIfStillCloseOfLinearElementEdge = (
+const getOriginalBindingsIfStillCloseToArrowEnds = (
   linearElement: NonDeleted<ExcalidrawLinearElement>,
-  edge: "start" | "end",
   elementsMap: NonDeletedSceneElementsMap,
   zoom?: AppState["zoom"],
-): NonDeleted<ExcalidrawElement> | null => {
-  const coors = getLinearElementEdgeCoors(linearElement, edge, elementsMap);
+): (NonDeleted<ExcalidrawElement> | null)[] =>
+  ["start", "end"].map((edge) => {
+    const coors = getLinearElementEdgeCoors(
+      linearElement,
+      edge as "start" | "end",
+      elementsMap,
+    );
   const elementId =
     edge === "start"
       ? linearElement.startBinding?.elementId
@@ -245,21 +249,7 @@ const getOriginalBindingIfStillCloseOfLinearElementEdge = (
   }
 
   return null;
-};
-
-const getOriginalBindingsIfStillCloseToArrowEnds = (
-  linearElement: NonDeleted<ExcalidrawLinearElement>,
-  elementsMap: NonDeletedSceneElementsMap,
-  zoom?: AppState["zoom"],
-): (NonDeleted<ExcalidrawElement> | null)[] =>
-  ["start", "end"].map((edge) =>
-    getOriginalBindingIfStillCloseOfLinearElementEdge(
-      linearElement,
-      edge as "start" | "end",
-      elementsMap,
-      zoom,
-    ),
-  );
+  });
 
 const getBindingStrategyForDraggingArrowEndpoints = (
   selectedElement: NonDeleted<ExcalidrawLinearElement>,