@antv/g6 5.0.49 → 5.0.50

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.
Files changed (129) hide show
  1. package/README.md +1 -1
  2. package/README.zh-CN.md +1 -1
  3. package/dist/g6.min.js +31 -31
  4. package/dist/lib/behaviors/brush-select.d.ts +1 -1
  5. package/dist/lib/behaviors/drag-element.d.ts +3 -2
  6. package/dist/lib/exports.d.ts +1 -1
  7. package/dist/lib/layouts/types.d.ts +9 -1
  8. package/dist/lib/plugins/index.d.ts +2 -0
  9. package/dist/lib/plugins/minimap/index.d.ts +7 -4
  10. package/dist/lib/plugins/title/index.d.ts +85 -0
  11. package/dist/lib/runtime/graph.d.ts +27 -0
  12. package/dist/lib/utils/element.d.ts +1 -1
  13. package/dist/lib/utils/vector.d.ts +9 -0
  14. package/dist/lib/version.d.ts +1 -1
  15. package/esm/behaviors/brush-select.d.ts +1 -1
  16. package/esm/behaviors/brush-select.js +12 -3
  17. package/esm/behaviors/brush-select.js.map +1 -1
  18. package/esm/behaviors/drag-canvas.js +2 -7
  19. package/esm/behaviors/drag-canvas.js.map +1 -1
  20. package/esm/behaviors/drag-element-force.js +1 -1
  21. package/esm/behaviors/drag-element-force.js.map +1 -1
  22. package/esm/behaviors/drag-element.d.ts +3 -2
  23. package/esm/behaviors/drag-element.js +6 -2
  24. package/esm/behaviors/drag-element.js.map +1 -1
  25. package/esm/behaviors/lasso-select.js +3 -3
  26. package/esm/behaviors/lasso-select.js.map +1 -1
  27. package/esm/exports.d.ts +1 -1
  28. package/esm/exports.js +1 -1
  29. package/esm/exports.js.map +1 -1
  30. package/esm/layouts/types.d.ts +9 -1
  31. package/esm/plugins/grid-line.js +1 -1
  32. package/esm/plugins/grid-line.js.map +1 -1
  33. package/esm/plugins/index.d.ts +2 -0
  34. package/esm/plugins/index.js +1 -0
  35. package/esm/plugins/index.js.map +1 -1
  36. package/esm/plugins/minimap/index.d.ts +7 -4
  37. package/esm/plugins/minimap/index.js +41 -52
  38. package/esm/plugins/minimap/index.js.map +1 -1
  39. package/esm/plugins/title/index.d.ts +85 -0
  40. package/esm/plugins/title/index.js +172 -0
  41. package/esm/plugins/title/index.js.map +1 -0
  42. package/esm/registry/build-in.js +2 -1
  43. package/esm/registry/build-in.js.map +1 -1
  44. package/esm/runtime/graph.d.ts +27 -0
  45. package/esm/runtime/graph.js +33 -0
  46. package/esm/runtime/graph.js.map +1 -1
  47. package/esm/runtime/layout.js +4 -3
  48. package/esm/runtime/layout.js.map +1 -1
  49. package/esm/runtime/viewport.js +3 -0
  50. package/esm/runtime/viewport.js.map +1 -1
  51. package/esm/themes/base.js +1 -0
  52. package/esm/themes/base.js.map +1 -1
  53. package/esm/transforms/process-parallel-edges.js +16 -3
  54. package/esm/transforms/process-parallel-edges.js.map +1 -1
  55. package/esm/utils/element.d.ts +1 -1
  56. package/esm/utils/element.js.map +1 -1
  57. package/esm/utils/vector.d.ts +9 -0
  58. package/esm/utils/vector.js +17 -0
  59. package/esm/utils/vector.js.map +1 -1
  60. package/esm/version.d.ts +1 -1
  61. package/esm/version.js +1 -1
  62. package/lib/behaviors/brush-select.d.ts +1 -1
  63. package/lib/behaviors/brush-select.js +12 -3
  64. package/lib/behaviors/brush-select.js.map +1 -1
  65. package/lib/behaviors/drag-canvas.js +1 -6
  66. package/lib/behaviors/drag-canvas.js.map +1 -1
  67. package/lib/behaviors/drag-element-force.js +1 -1
  68. package/lib/behaviors/drag-element-force.js.map +1 -1
  69. package/lib/behaviors/drag-element.d.ts +3 -2
  70. package/lib/behaviors/drag-element.js +5 -1
  71. package/lib/behaviors/drag-element.js.map +1 -1
  72. package/lib/behaviors/lasso-select.js +3 -3
  73. package/lib/behaviors/lasso-select.js.map +1 -1
  74. package/lib/exports.d.ts +1 -1
  75. package/lib/exports.js +3 -2
  76. package/lib/exports.js.map +1 -1
  77. package/lib/layouts/types.d.ts +9 -1
  78. package/lib/plugins/grid-line.js +1 -1
  79. package/lib/plugins/grid-line.js.map +1 -1
  80. package/lib/plugins/index.d.ts +2 -0
  81. package/lib/plugins/index.js +3 -1
  82. package/lib/plugins/index.js.map +1 -1
  83. package/lib/plugins/minimap/index.d.ts +7 -4
  84. package/lib/plugins/minimap/index.js +41 -52
  85. package/lib/plugins/minimap/index.js.map +1 -1
  86. package/lib/plugins/title/index.d.ts +85 -0
  87. package/lib/plugins/title/index.js +176 -0
  88. package/lib/plugins/title/index.js.map +1 -0
  89. package/lib/registry/build-in.js +1 -0
  90. package/lib/registry/build-in.js.map +1 -1
  91. package/lib/runtime/graph.d.ts +27 -0
  92. package/lib/runtime/graph.js +33 -0
  93. package/lib/runtime/graph.js.map +1 -1
  94. package/lib/runtime/layout.js +4 -3
  95. package/lib/runtime/layout.js.map +1 -1
  96. package/lib/runtime/viewport.js +3 -0
  97. package/lib/runtime/viewport.js.map +1 -1
  98. package/lib/themes/base.js +1 -0
  99. package/lib/themes/base.js.map +1 -1
  100. package/lib/transforms/process-parallel-edges.js +16 -3
  101. package/lib/transforms/process-parallel-edges.js.map +1 -1
  102. package/lib/utils/element.d.ts +1 -1
  103. package/lib/utils/element.js.map +1 -1
  104. package/lib/utils/vector.d.ts +9 -0
  105. package/lib/utils/vector.js +18 -0
  106. package/lib/utils/vector.js.map +1 -1
  107. package/lib/version.d.ts +1 -1
  108. package/lib/version.js +1 -1
  109. package/package.json +8 -8
  110. package/src/behaviors/brush-select.ts +14 -3
  111. package/src/behaviors/drag-canvas.ts +2 -6
  112. package/src/behaviors/drag-element-force.ts +2 -1
  113. package/src/behaviors/drag-element.ts +8 -3
  114. package/src/behaviors/lasso-select.ts +3 -3
  115. package/src/exports.ts +1 -0
  116. package/src/layouts/types.ts +9 -1
  117. package/src/plugins/grid-line.ts +1 -1
  118. package/src/plugins/index.ts +2 -0
  119. package/src/plugins/minimap/index.ts +50 -63
  120. package/src/plugins/title/index.ts +300 -0
  121. package/src/registry/build-in.ts +2 -0
  122. package/src/runtime/graph.ts +34 -0
  123. package/src/runtime/layout.ts +9 -3
  124. package/src/runtime/viewport.ts +14 -3
  125. package/src/themes/base.ts +1 -0
  126. package/src/transforms/process-parallel-edges.ts +17 -3
  127. package/src/utils/element.ts +5 -5
  128. package/src/utils/vector.ts +17 -0
  129. package/src/version.ts +1 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@antv/g6",
3
- "version": "5.0.49",
3
+ "version": "5.0.50",
4
4
  "description": "A Graph Visualization Framework in JavaScript",
5
5
  "keywords": [
6
6
  "antv",
@@ -33,20 +33,20 @@
33
33
  ],
34
34
  "dependencies": {
35
35
  "@antv/algorithm": "^0.1.26",
36
- "@antv/component": "^2.1.3",
36
+ "@antv/component": "^2.1.7",
37
37
  "@antv/event-emitter": "^0.1.3",
38
- "@antv/g": "^6.1.24",
39
- "@antv/g-canvas": "^2.0.43",
40
- "@antv/g-plugin-dragndrop": "^2.0.35",
38
+ "@antv/g": "^6.1.28",
39
+ "@antv/g-canvas": "^2.0.48",
40
+ "@antv/g-plugin-dragndrop": "^2.0.38",
41
41
  "@antv/graphlib": "^2.0.4",
42
42
  "@antv/hierarchy": "^0.6.14",
43
43
  "@antv/layout": "1.2.14-beta.9",
44
- "@antv/util": "^3.3.10",
44
+ "@antv/util": "^3.3.11",
45
45
  "bubblesets-js": "^2.3.4"
46
46
  },
47
47
  "devDependencies": {
48
- "@antv/g-svg": "^2.0.38",
49
- "@antv/g-webgl": "^2.0.47",
48
+ "@antv/g-svg": "^2.0.42",
49
+ "@antv/g-webgl": "^2.0.52",
50
50
  "@antv/layout-gpu": "^1.1.7",
51
51
  "@antv/layout-wasm": "^1.4.2",
52
52
  "@antv/vendor": "^1.0.11",
@@ -168,7 +168,7 @@ export class BrushSelect extends BaseBehavior<BrushSelectOptions> {
168
168
  if (!this.startPoint) return;
169
169
  const { immediately, mode } = this.options;
170
170
 
171
- this.endPoint = getCursorPoint(event);
171
+ this.endPoint = getCursorPoint(event, this.context.graph);
172
172
 
173
173
  this.rectShape?.attr({
174
174
  x: Math.min(this.endPoint[0], this.startPoint[0]),
@@ -192,7 +192,7 @@ export class BrushSelect extends BaseBehavior<BrushSelectOptions> {
192
192
  return;
193
193
  }
194
194
 
195
- this.endPoint = getCursorPoint(event);
195
+ this.endPoint = getCursorPoint(event, this.context.graph);
196
196
  this.updateElementsStates(getBoundingPoints(this.startPoint, this.endPoint));
197
197
 
198
198
  this.clearBrush();
@@ -396,6 +396,17 @@ export class BrushSelect extends BaseBehavior<BrushSelectOptions> {
396
396
  }
397
397
  }
398
398
 
399
- export const getCursorPoint = (event: IPointerEvent): Point => {
399
+ export const getCursorPoint = (event: IPointerEvent, graph: Graph): Point => {
400
+ // Fixed #7182: 判断 html 类型节点,并把 html 节点的浏览器坐标转换为 canvas 坐标。
401
+ // 没有直接判断的方式,nativeEvent.target 非 canvas 则表示 html 节点触发的。
402
+ // Fixed #7182: Handles brush selection on HTML nodes by converting client coordinates to canvas coordinates.
403
+ // An HTML node is identified if the event's targetType is 'node' but the nativeEvent.target is not the canvas element.
404
+ if (
405
+ (event.targetType === 'node' || event.targetType === 'combo') &&
406
+ !(event.nativeEvent.target instanceof HTMLCanvasElement)
407
+ ) {
408
+ const [x, y] = graph.getCanvasByClient([event.client.x, event.client.y]);
409
+ return [x, y];
410
+ }
400
411
  return [event.canvas.x, event.canvas.y];
401
412
  };
@@ -8,7 +8,7 @@ import { parsePadding } from '../utils/padding';
8
8
  import { PinchHandler } from '../utils/pinch';
9
9
  import type { ShortcutKey } from '../utils/shortcut';
10
10
  import { Shortcut } from '../utils/shortcut';
11
- import { multiply, subtract } from '../utils/vector';
11
+ import { multiply, rotate, subtract } from '../utils/vector';
12
12
  import type { BaseBehaviorOptions } from './base-behavior';
13
13
  import { BaseBehavior } from './base-behavior';
14
14
 
@@ -190,11 +190,7 @@ export class DragCanvas extends BaseBehavior<DragCanvasOptions> {
190
190
 
191
191
  private clampByRotation([dx, dy]: Vector2): Vector2 {
192
192
  const rotation = this.context.graph.getRotation();
193
- if (rotation % 360 === 0) return [dx, dy];
194
- const rad = (rotation * Math.PI) / 180;
195
- const cos = Math.cos(rad);
196
- const sin = Math.sin(rad);
197
- return [dx * cos - dy * sin, dx * sin + dy * cos];
193
+ return rotate([dx, dy], rotation);
198
194
  }
199
195
 
200
196
  private clampByDirection([dx, dy]: Vector2): Vector2 {
@@ -66,7 +66,8 @@ export class DragElementForce extends DragElement {
66
66
  const layout = this.forceLayoutInstance;
67
67
  this.context.graph.getNodeData(ids).forEach((element, index) => {
68
68
  const { x = 0, y = 0 } = element.style || {};
69
- if (layout) invokeLayoutMethod(layout, 'setFixedPosition', ids[index], [...add([+x, +y], offset)]);
69
+ if (layout)
70
+ invokeLayoutMethod(layout, 'setFixedPosition', ids[index], [...add([+x, +y], this.clampByRotation(offset))]);
70
71
  });
71
72
  }
72
73
 
@@ -3,12 +3,12 @@ import { Rect } from '@antv/g';
3
3
  import { isFunction } from '@antv/util';
4
4
  import { COMBO_KEY, CanvasEvent, ComboEvent, CommonEvent } from '../constants';
5
5
  import type { RuntimeContext } from '../runtime/types';
6
- import type { EdgeDirection, ID, IElementDragEvent, IPointerEvent, Point, Prefix, State } from '../types';
6
+ import type { EdgeDirection, ID, IElementDragEvent, IPointerEvent, Point, Prefix, State, Vector2 } from '../types';
7
7
  import { getBBoxSize, getCombinedBBox } from '../utils/bbox';
8
8
  import { isToBeDestroyed } from '../utils/element';
9
9
  import { idOf } from '../utils/id';
10
10
  import { subStyleProps } from '../utils/prefix';
11
- import { divide, subtract } from '../utils/vector';
11
+ import { divide, rotate, subtract } from '../utils/vector';
12
12
  import type { BaseBehaviorOptions } from './base-behavior';
13
13
  import { BaseBehavior } from './base-behavior';
14
14
 
@@ -354,6 +354,11 @@ export class DragElement extends BaseBehavior<DragElementOptions> {
354
354
  return !!enable;
355
355
  }
356
356
 
357
+ protected clampByRotation([dx, dy]: Point): Vector2 {
358
+ const rotation = this.context.graph.getRotation();
359
+ return rotate([dx, dy], rotation);
360
+ }
361
+
357
362
  /**
358
363
  * <zh/> 移动元素
359
364
  *
@@ -367,7 +372,7 @@ export class DragElement extends BaseBehavior<DragElementOptions> {
367
372
  const { dropEffect } = this.options;
368
373
 
369
374
  if (dropEffect === 'move') ids.forEach((id) => model.refreshComboData(id));
370
- graph.translateElementBy(Object.fromEntries(ids.map((id) => [id, offset])), false);
375
+ graph.translateElementBy(Object.fromEntries(ids.map((id) => [id, this.clampByRotation(offset)])), false);
371
376
  }
372
377
 
373
378
  private moveShadow(offset: Point) {
@@ -31,7 +31,7 @@ export class LassoSelect extends BrushSelect {
31
31
  */
32
32
  protected onPointerDown(event: IPointerEvent) {
33
33
  if (!super.validate(event) || !super.isKeydown() || this.points) return;
34
- const { canvas } = this.context;
34
+ const { canvas, graph } = this.context;
35
35
 
36
36
  this.pathShape = new Path({
37
37
  id: 'g6-lasso-select',
@@ -40,7 +40,7 @@ export class LassoSelect extends BrushSelect {
40
40
 
41
41
  canvas.appendChild(this.pathShape);
42
42
 
43
- this.points = [getCursorPoint(event)];
43
+ this.points = [getCursorPoint(event, graph)];
44
44
  }
45
45
 
46
46
  /**
@@ -52,7 +52,7 @@ export class LassoSelect extends BrushSelect {
52
52
  if (!this.points) return;
53
53
  const { immediately, mode } = this.options;
54
54
 
55
- this.points.push(getCursorPoint(event));
55
+ this.points.push(getCursorPoint(event, this.context.graph));
56
56
 
57
57
  this.pathShape?.setAttribute('d', pointsToPath(this.points));
58
58
 
package/src/exports.ts CHANGED
@@ -92,6 +92,7 @@ export {
92
92
  Minimap,
93
93
  Snapline,
94
94
  Timebar,
95
+ Title,
95
96
  Toolbar,
96
97
  Tooltip,
97
98
  Watermark,
@@ -15,7 +15,7 @@ import type {
15
15
  RadialLayoutOptions,
16
16
  RandomLayoutOptions,
17
17
  } from '@antv/layout';
18
- import type { NodeData } from '../spec/data';
18
+ import type { ComboData, NodeData } from '../spec/data';
19
19
  import type { BaseLayout } from './base-layout';
20
20
  import type { FishboneLayoutOptions } from './fishbone';
21
21
  import type { SnakeLayoutOptions } from './snake';
@@ -52,6 +52,14 @@ export interface BaseLayoutOptions extends AnimationOptions, WebWorkerLayoutOpti
52
52
  * @returns <zh/> 是否参与布局 | <en/> Whether to participate in the layout
53
53
  */
54
54
  nodeFilter?: (node: NodeData) => boolean;
55
+ /**
56
+ * <zh/> 参与该布局的combo元素
57
+ *
58
+ * <en/> Combos involved in the layout
59
+ * @param node - <zh/> combo数据 | <en/> combo data
60
+ * @returns <zh/> 是否参与布局 | <en/> Whether to participate in the layout
61
+ */
62
+ comboFilter?: (combo: ComboData) => boolean;
55
63
  /**
56
64
  * <zh/> 使用前布局,在初始化元素前计算布局
57
65
  *
@@ -177,7 +177,7 @@ export class GridLine extends BasePlugin<GridLineOptions> {
177
177
  data: { scale, origin },
178
178
  } = event;
179
179
 
180
- if (!scale) return;
180
+ if (!scale || (origin === undefined && this.context.viewport === undefined)) return;
181
181
 
182
182
  const prevScale = this.currentScale;
183
183
  this.currentScale = scale;
@@ -14,6 +14,7 @@ export { Legend } from './legend';
14
14
  export { Minimap } from './minimap';
15
15
  export { Snapline } from './snapline';
16
16
  export { Timebar } from './timebar';
17
+ export { Title } from './title';
17
18
  export { Toolbar } from './toolbar';
18
19
  export { Tooltip } from './tooltip';
19
20
  export { Watermark } from './watermark';
@@ -34,6 +35,7 @@ export type { LegendOptions } from './legend';
34
35
  export type { MinimapOptions } from './minimap';
35
36
  export type { SnaplineOptions } from './snapline';
36
37
  export type { TimebarOptions } from './timebar';
38
+ export type { SubTitleStyle, TitleOptions, TitleStyle } from './title';
37
39
  export type { ToolbarOptions } from './toolbar';
38
40
  export type { TooltipOptions } from './tooltip';
39
41
  export type { WatermarkOptions } from './watermark';
@@ -3,7 +3,7 @@ import { debounce, throttle } from '@antv/util';
3
3
  import { GraphEvent } from '../../constants';
4
4
  import type { RuntimeContext } from '../../runtime/types';
5
5
  import { GraphData } from '../../spec';
6
- import type { ElementDatum, ElementType, ID, IGraphLifeCycleEvent, Padding, Placement, Vector3 } from '../../types';
6
+ import type { ElementDatum, ElementType, IGraphLifeCycleEvent, Padding, Placement, Vector3 } from '../../types';
7
7
  import { isVisible } from '../../utils/element';
8
8
  import { idOf } from '../../utils/id';
9
9
  import { parsePadding } from '../../utils/padding';
@@ -56,13 +56,17 @@ export interface MinimapOptions extends BasePluginOptions {
56
56
  * @remarks
57
57
  * <zh/>
58
58
  * - 'key' 使用元素的主图形作为缩略图形
59
- * - 也可以传入一个函数,接收元素的 id 和类型,返回一个图形
59
+ * - 'icon' 使用元素中心的 icon 作为缩略图形
60
+ * - 更多图形名称可查阅 https://g6.antv.antgroup.com/manual/element/node/base-node#style
61
+ * - 也可以传入一个函数,接收元素的 [id, 类型, 元素节点],返回一个自定义样式的图形
60
62
  *
61
63
  * <en/>
62
64
  * - 'key' uses the key shape of the element as the thumbnail shape
63
- * - You can also pass in a function that receives the id and type of the element and returns a shape
65
+ * - 'icon' uses the icon shape of the element as the thumbnail shape
66
+ * - more shape name see https://g6.antv.antgroup.com/manual/element/node/base-node#style
67
+ * - You can also pass in a function that receives the [id, type of the element, element] and returns a custom shape
64
68
  */
65
- shape?: 'key' | ((id: string, elementType: ElementType) => DisplayObject);
69
+ shape?: string | 'key' | 'icon' | ((id: string, elementType: ElementType, element: DisplayObject) => DisplayObject);
66
70
  /**
67
71
  * <zh/> 缩略图画布类名,传入外置容器时不生效
68
72
  *
@@ -169,8 +173,6 @@ export class Minimap extends BasePlugin<MinimapOptions> {
169
173
 
170
174
  private onRender!: () => void;
171
175
 
172
- private shapes = new Map<ID, DisplayObject>();
173
-
174
176
  /**
175
177
  * <zh/> 创建或更新缩略图
176
178
  *
@@ -214,65 +216,46 @@ export class Minimap extends BasePlugin<MinimapOptions> {
214
216
  const { shape } = this.options;
215
217
  const { element } = this.context;
216
218
 
217
- if (shape === 'key') {
218
- const ids = new Set<ID>();
219
-
220
- const iterate = (datum: ElementDatum) => {
221
- const id = idOf(datum);
222
- ids.add(id);
223
-
224
- const target = element!.getElement(id);
225
- if (!target) return;
226
-
227
- const shape = target.getShape('key');
228
- const cloneShape = this.shapes.get(id) || shape.cloneNode();
229
-
230
- cloneShape.setPosition(shape.getPosition());
231
- // keep zIndex / id
232
- if (target.style.zIndex) cloneShape.style.zIndex = target.style.zIndex;
233
- cloneShape.id = target.id;
234
-
235
- if (!this.shapes.has(id)) {
236
- canvas.appendChild(cloneShape);
237
- this.shapes.set(id, cloneShape);
219
+ const iterate = (datum: ElementDatum, elType: ElementType) => {
220
+ const id = idOf(datum);
221
+ const target = element?.getElement(id);
222
+ if (!target) return;
223
+
224
+ const keyShape = target.getShape('key');
225
+ let cloneShape: DisplayObject;
226
+
227
+ if (typeof shape === 'string') {
228
+ const shapeName = shape;
229
+ const miniShape = target.getShape(shapeName);
230
+ cloneShape = miniShape.cloneNode();
231
+ } else {
232
+ const miniShape = shape(id, elType, target);
233
+ if (miniShape === target) {
234
+ cloneShape = miniShape.cloneNode(true);
238
235
  } else {
239
- Object.entries(shape.attributes).forEach(([key, value]) => {
240
- if (cloneShape.style[key] !== value) cloneShape.style[key] = value;
241
- });
236
+ cloneShape = miniShape;
242
237
  }
243
- };
244
-
245
- // 注意执行顺序 / Note the execution order
246
- edges.forEach(iterate);
247
- combos.forEach(iterate);
248
- nodes.forEach(iterate);
249
-
250
- this.shapes.forEach((shape, id) => {
251
- if (!ids.has(id)) {
252
- canvas.removeChild(shape);
253
- this.shapes.delete(id);
254
- }
255
- });
256
-
257
- return;
258
- }
259
-
260
- const setPosition = (id: ID, shape: DisplayObject) => {
261
- const target = element!.getElement(id)!;
262
- const position = target.getPosition();
263
- shape.setPosition(position);
264
- return shape;
238
+ }
239
+
240
+ /**
241
+ * 这里使用的是 keyShape 的位置
242
+ * 对于整个元素的位置而言,使用 keyShape 位置会比较准确
243
+ * 也比较合理
244
+ */
245
+ cloneShape.setPosition(keyShape.getPosition());
246
+ // keep zIndex / id
247
+ if (target.style.zIndex) cloneShape.style.zIndex = target.style.zIndex;
248
+ cloneShape.id = target.id;
249
+
250
+ canvas.appendChild(cloneShape);
265
251
  };
266
252
 
267
253
  canvas.removeChildren();
268
254
 
269
- edges.forEach((datum) => canvas.appendChild(shape(idOf(datum), 'edge')));
270
- combos.forEach((datum) => {
271
- canvas.appendChild(setPosition(idOf(datum), shape(idOf(datum), 'combo')));
272
- });
273
- nodes.forEach((datum) => {
274
- canvas.appendChild(setPosition(idOf(datum), shape(idOf(datum), 'node')));
275
- });
255
+ // 注意执行顺序 / Note the execution order
256
+ edges.forEach((datum) => iterate(datum, 'edge'));
257
+ combos.forEach((datum) => iterate(datum, 'combo'));
258
+ nodes.forEach((datum) => iterate(datum, 'node'));
276
259
  }
277
260
 
278
261
  private container!: HTMLElement;
@@ -463,12 +446,16 @@ export class Minimap extends BasePlugin<MinimapOptions> {
463
446
  // 当拖拽画布导致 mask 缩小时,拖拽 mask 时,能够恢复到实际大小
464
447
  // When dragging the canvas causes the mask to shrink, dragging the mask will restore it to its actual size
465
448
  if (width < fullWidth) {
466
- if (movementX > 0) ((x = lower(x - movementX, 0)), (width = upper(width + movementX, minimapWidth)));
467
- else if (movementX < 0) width = upper(width - movementX, minimapWidth);
449
+ if (movementX > 0) {
450
+ x = lower(x - movementX, 0);
451
+ width = upper(width + movementX, minimapWidth);
452
+ } else if (movementX < 0) width = upper(width - movementX, minimapWidth);
468
453
  }
469
454
  if (height < fullHeight) {
470
- if (movementY > 0) ((y = lower(y - movementY, 0)), (height = upper(height + movementY, minimapHeight)));
471
- else if (movementY < 0) height = upper(height - movementY, minimapHeight);
455
+ if (movementY > 0) {
456
+ y = lower(y - movementY, 0);
457
+ height = upper(height + movementY, minimapHeight);
458
+ } else if (movementY < 0) height = upper(height - movementY, minimapHeight);
472
459
  }
473
460
 
474
461
  Object.assign(this.mask.style, {