浏览代码

Fix text selection broken by PR1899 (#2011)

Michal Srb 4 年之前
父节点
当前提交
8bbeb32e87
共有 1 个文件被更改,包括 10 次插入3 次删除
  1. 10 3
      src/element/collision.ts

+ 10 - 3
src/element/collision.ts

@@ -48,9 +48,12 @@ export const hitTest = (
 ): boolean => {
   // How many pixels off the shape boundary we still consider a hit
   const threshold = 10 / appState.zoom;
-  const check = isElementDraggableFromInside(element, appState)
-    ? isInsideCheck
-    : isNearCheck;
+  const check =
+    element.type === "text"
+      ? isStrictlyInside
+      : isElementDraggableFromInside(element, appState)
+      ? isInsideCheck
+      : isNearCheck;
   const point: Point = [x, y];
   return hitTestPointAgainstElement({ element, point, threshold, check });
 };
@@ -119,6 +122,10 @@ export const distanceToBindableElement = (
   }
 };
 
+const isStrictlyInside = (distance: number, threshold: number): boolean => {
+  return distance < 0;
+};
+
 const isInsideCheck = (distance: number, threshold: number): boolean => {
   return distance < threshold;
 };