reactflow-edge-routing 0.1.6 → 0.1.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "reactflow-edge-routing",
3
- "version": "0.1.6",
3
+ "version": "0.1.7",
4
4
  "description": "Orthogonal edge routing for React Flow using obstacle-router. Edges route around nodes while pins stay fixed at their anchor points.",
5
5
  "main": "./src/index.ts",
6
6
  "types": "./src/index.ts",
@@ -287,8 +287,7 @@ function segmentIntersectsRect(
287
287
  return tMin <= tMax;
288
288
  }
289
289
 
290
- /** Returns true if the direct line from srcPt to tgtPt is blocked by any node,
291
- * including the source/target nodes themselves (e.g. edge going backward through its own node). */
290
+ /** Returns true if the direct line from srcPt to tgtPt is blocked by any node except the source/target nodes. */
292
291
  function isEdgeDirectPathBlocked(
293
292
  srcPt: { x: number; y: number },
294
293
  tgtPt: { x: number; y: number },
@@ -298,25 +297,10 @@ function isEdgeDirectPathBlocked(
298
297
  nodeById: Map<string, FlowNode>,
299
298
  buffer: number
300
299
  ): boolean {
301
- const dx = tgtPt.x - srcPt.x, dy = tgtPt.y - srcPt.y;
302
- const len = Math.sqrt(dx * dx + dy * dy);
303
300
  for (const node of nodes) {
304
301
  const bounds = Geometry.getNodeBoundsAbsolute(node, nodeById);
305
- if (node.id === srcNodeId || node.id === tgtNodeId) {
306
- // The handle point sits on the node border, so a plain intersection check would
307
- // always trigger. Nudge 1 px along the segment away from the handle and check
308
- // from there — avoids the border false-positive while still catching lines that
309
- // go backward through the node body.
310
- if (len < 1e-6) continue;
311
- const isSrc = node.id === srcNodeId;
312
- const nudged = isSrc
313
- ? { x: srcPt.x + dx / len, y: srcPt.y + dy / len }
314
- : { x: tgtPt.x - dx / len, y: tgtPt.y - dy / len };
315
- const otherEnd = isSrc ? tgtPt : srcPt;
316
- if (segmentIntersectsRect(nudged, otherEnd, bounds, buffer)) return true;
317
- } else {
318
- if (segmentIntersectsRect(srcPt, tgtPt, bounds, buffer)) return true;
319
- }
302
+ if (node.id === srcNodeId || node.id === tgtNodeId) continue;
303
+ if (segmentIntersectsRect(srcPt, tgtPt, bounds, buffer)) return true;
320
304
  }
321
305
  return false;
322
306
  }