@logicflow/core 2.1.2 → 2.1.3

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.
@@ -282,12 +282,21 @@ var BaseEdge = /** @class */ (function (_super) {
282
282
  var _a = model.getArrowStyle(), _b = _a.refY, refY = _b === void 0 ? 0 : _b, _c = _a.refX, refX = _c === void 0 ? 2 : _c;
283
283
  var _d = __read(this.getLastTwoPoints(), 2), start = _d[0], end = _d[1];
284
284
  var theta = 'auto';
285
- if (start !== null && end !== null) {
286
- theta = degrees(getThetaOfVector({
287
- x: end.x - start.x,
288
- y: end.y - start.y,
289
- z: 0,
290
- }));
285
+ // 防止无效点和零长度向量以避免 NaN 方向
286
+ if (start && end) {
287
+ var dx = end.x - start.x;
288
+ var dy = end.y - start.y;
289
+ // 仅在有实际方向时才计算
290
+ if (dx !== 0 || dy !== 0) {
291
+ var computed = degrees(getThetaOfVector({
292
+ x: dx,
293
+ y: dy,
294
+ z: 0,
295
+ }));
296
+ if (Number.isFinite(computed) && !Number.isNaN(computed)) {
297
+ theta = computed;
298
+ }
299
+ }
291
300
  }
292
301
  return (_jsx("g", { children: _jsxs("defs", { children: [_jsx("marker", { id: "marker-start-".concat(id), refX: -refX, refY: refY, overflow: "visible", orient: "auto", markerUnits: "userSpaceOnUse", children: this.getStartArrow() }), _jsx("marker", { id: "marker-end-".concat(id), refX: refX, refY: refY, overflow: "visible", orient: theta, markerUnits: "userSpaceOnUse", children: this.getEndArrow() })] }) }));
293
302
  };
@@ -308,12 +308,21 @@ var BaseEdge = /** @class */ (function (_super) {
308
308
  var _a = model.getArrowStyle(), _b = _a.refY, refY = _b === void 0 ? 0 : _b, _c = _a.refX, refX = _c === void 0 ? 2 : _c;
309
309
  var _d = __read(this.getLastTwoPoints(), 2), start = _d[0], end = _d[1];
310
310
  var theta = 'auto';
311
- if (start !== null && end !== null) {
312
- theta = (0, util_1.degrees)((0, util_1.getThetaOfVector)({
313
- x: end.x - start.x,
314
- y: end.y - start.y,
315
- z: 0,
316
- }));
311
+ // 防止无效点和零长度向量以避免 NaN 方向
312
+ if (start && end) {
313
+ var dx = end.x - start.x;
314
+ var dy = end.y - start.y;
315
+ // 仅在有实际方向时才计算
316
+ if (dx !== 0 || dy !== 0) {
317
+ var computed = (0, util_1.degrees)((0, util_1.getThetaOfVector)({
318
+ x: dx,
319
+ y: dy,
320
+ z: 0,
321
+ }));
322
+ if (Number.isFinite(computed) && !Number.isNaN(computed)) {
323
+ theta = computed;
324
+ }
325
+ }
317
326
  }
318
327
  return ((0, jsx_runtime_1.jsx)("g", { children: (0, jsx_runtime_1.jsxs)("defs", { children: [(0, jsx_runtime_1.jsx)("marker", { id: "marker-start-".concat(id), refX: -refX, refY: refY, overflow: "visible", orient: "auto", markerUnits: "userSpaceOnUse", children: this.getStartArrow() }), (0, jsx_runtime_1.jsx)("marker", { id: "marker-end-".concat(id), refX: refX, refY: refY, overflow: "visible", orient: theta, markerUnits: "userSpaceOnUse", children: this.getEndArrow() })] }) }));
319
328
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@logicflow/core",
3
- "version": "2.1.2",
3
+ "version": "2.1.3",
4
4
  "description": "LogicFlow, help you quickly create flowcharts",
5
5
  "main": "lib/index.js",
6
6
  "module": "es/index.js",
@@ -124,14 +124,23 @@ export abstract class BaseEdge<P extends IProps> extends Component<
124
124
  const { refY = 0, refX = 2 } = model.getArrowStyle()
125
125
  const [start, end] = this.getLastTwoPoints()
126
126
  let theta: string | number = 'auto'
127
- if (start !== null && end !== null) {
128
- theta = degrees(
129
- getThetaOfVector({
130
- x: end.x - start.x,
131
- y: end.y - start.y,
132
- z: 0,
133
- }),
134
- )
127
+ // 防止无效点和零长度向量以避免 NaN 方向
128
+ if (start && end) {
129
+ const dx = end.x - start.x
130
+ const dy = end.y - start.y
131
+ // 仅在有实际方向时才计算
132
+ if (dx !== 0 || dy !== 0) {
133
+ const computed = degrees(
134
+ getThetaOfVector({
135
+ x: dx,
136
+ y: dy,
137
+ z: 0,
138
+ }),
139
+ )
140
+ if (Number.isFinite(computed) && !Number.isNaN(computed)) {
141
+ theta = computed
142
+ }
143
+ }
135
144
  }
136
145
  return (
137
146
  <g>