@antv/g6 5.0.0-beta.4 → 5.0.0-beta.5

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 (168) hide show
  1. package/dist/g6.min.js +2 -2
  2. package/esm/index.d.ts +3 -1
  3. package/esm/index.js +1 -1
  4. package/esm/item/edge.d.ts +1 -0
  5. package/esm/item/edge.js +3 -1
  6. package/esm/item/edge.js.map +1 -1
  7. package/esm/item/item.d.ts +3 -2
  8. package/esm/item/item.js +12 -6
  9. package/esm/item/item.js.map +1 -1
  10. package/esm/item/node.d.ts +1 -0
  11. package/esm/item/node.js +3 -1
  12. package/esm/item/node.js.map +1 -1
  13. package/esm/runtime/controller/item.js +252 -148
  14. package/esm/runtime/controller/item.js.map +1 -1
  15. package/esm/runtime/graph.d.ts +16 -14
  16. package/esm/runtime/graph.js +66 -28
  17. package/esm/runtime/graph.js.map +1 -1
  18. package/esm/stdlib/behavior/activate-relations.js +2 -2
  19. package/esm/stdlib/behavior/activate-relations.js.map +1 -1
  20. package/esm/stdlib/behavior/click-select.js +1 -1
  21. package/esm/stdlib/behavior/click-select.js.map +1 -1
  22. package/esm/stdlib/behavior/drag-canvas.js +50 -27
  23. package/esm/stdlib/behavior/drag-canvas.js.map +1 -1
  24. package/esm/stdlib/behavior/drag-combo.js +8 -8
  25. package/esm/stdlib/behavior/drag-combo.js.map +1 -1
  26. package/esm/stdlib/behavior/drag-node.js +10 -10
  27. package/esm/stdlib/behavior/drag-node.js.map +1 -1
  28. package/esm/stdlib/behavior/zoom-canvas.js +47 -24
  29. package/esm/stdlib/behavior/zoom-canvas.js.map +1 -1
  30. package/esm/stdlib/index.d.ts +2 -0
  31. package/esm/stdlib/index.js +10 -8
  32. package/esm/stdlib/index.js.map +1 -1
  33. package/esm/stdlib/item/edge/base.d.ts +1 -1
  34. package/esm/stdlib/item/edge/base.js +13 -4
  35. package/esm/stdlib/item/edge/base.js.map +1 -1
  36. package/esm/stdlib/item/node/base.d.ts +1 -1
  37. package/esm/stdlib/item/node/base.js +11 -12
  38. package/esm/stdlib/item/node/base.js.map +1 -1
  39. package/esm/stdlib/item/node/image.d.ts +1 -1
  40. package/esm/stdlib/item/node/image.js +1 -1
  41. package/esm/stdlib/item/node/image.js.map +1 -1
  42. package/esm/stdlib/plugin/history/combo-command.js +2 -2
  43. package/esm/stdlib/plugin/history/combo-command.js.map +1 -1
  44. package/esm/stdlib/plugin/history/index.d.ts +10 -10
  45. package/esm/stdlib/plugin/history/index.js +14 -14
  46. package/esm/stdlib/plugin/history/index.js.map +1 -1
  47. package/esm/stdlib/plugin/history/item-data-command.js +4 -4
  48. package/esm/stdlib/plugin/history/item-data-command.js.map +1 -1
  49. package/esm/stdlib/plugin/history/layer-updated-command.js +2 -2
  50. package/esm/stdlib/plugin/history/layer-updated-command.js.map +1 -1
  51. package/esm/stdlib/plugin/history/state-updated-command.js +1 -1
  52. package/esm/stdlib/plugin/history/state-updated-command.js.map +1 -1
  53. package/esm/stdlib/plugin/history/visibility-updated-command.js +2 -2
  54. package/esm/stdlib/plugin/history/visibility-updated-command.js.map +1 -1
  55. package/esm/stdlib/plugin/index.d.ts +1 -0
  56. package/esm/stdlib/plugin/index.js +1 -0
  57. package/esm/stdlib/plugin/index.js.map +1 -1
  58. package/esm/stdlib/plugin/snapline/index.d.ts +163 -0
  59. package/esm/stdlib/plugin/snapline/index.js +1052 -0
  60. package/esm/stdlib/plugin/snapline/index.js.map +1 -0
  61. package/esm/stdlib/plugin/types.d.ts +1 -0
  62. package/esm/types/graph.d.ts +14 -14
  63. package/esm/types/hook.d.ts +6 -0
  64. package/esm/types/spec.d.ts +13 -0
  65. package/esm/util/bbox.d.ts +16 -1
  66. package/esm/util/bbox.js +29 -0
  67. package/esm/util/bbox.js.map +1 -1
  68. package/esm/util/shape.js +2 -2
  69. package/esm/util/shape.js.map +1 -1
  70. package/lib/index.d.ts +3 -1
  71. package/lib/index.js +1 -1
  72. package/lib/item/edge.d.ts +1 -0
  73. package/lib/item/edge.js +3 -1
  74. package/lib/item/edge.js.map +1 -1
  75. package/lib/item/item.d.ts +3 -2
  76. package/lib/item/item.js +12 -6
  77. package/lib/item/item.js.map +1 -1
  78. package/lib/item/node.d.ts +1 -0
  79. package/lib/item/node.js +3 -1
  80. package/lib/item/node.js.map +1 -1
  81. package/lib/runtime/controller/item.js +251 -147
  82. package/lib/runtime/controller/item.js.map +1 -1
  83. package/lib/runtime/graph.d.ts +16 -14
  84. package/lib/runtime/graph.js +66 -28
  85. package/lib/runtime/graph.js.map +1 -1
  86. package/lib/stdlib/behavior/activate-relations.js +2 -2
  87. package/lib/stdlib/behavior/activate-relations.js.map +1 -1
  88. package/lib/stdlib/behavior/click-select.js +1 -1
  89. package/lib/stdlib/behavior/click-select.js.map +1 -1
  90. package/lib/stdlib/behavior/drag-canvas.js +50 -27
  91. package/lib/stdlib/behavior/drag-canvas.js.map +1 -1
  92. package/lib/stdlib/behavior/drag-combo.js +8 -8
  93. package/lib/stdlib/behavior/drag-combo.js.map +1 -1
  94. package/lib/stdlib/behavior/drag-node.js +10 -10
  95. package/lib/stdlib/behavior/drag-node.js.map +1 -1
  96. package/lib/stdlib/behavior/zoom-canvas.js +47 -24
  97. package/lib/stdlib/behavior/zoom-canvas.js.map +1 -1
  98. package/lib/stdlib/index.d.ts +2 -0
  99. package/lib/stdlib/index.js +10 -8
  100. package/lib/stdlib/index.js.map +1 -1
  101. package/lib/stdlib/item/edge/base.d.ts +1 -1
  102. package/lib/stdlib/item/edge/base.js +13 -4
  103. package/lib/stdlib/item/edge/base.js.map +1 -1
  104. package/lib/stdlib/item/node/base.d.ts +1 -1
  105. package/lib/stdlib/item/node/base.js +11 -12
  106. package/lib/stdlib/item/node/base.js.map +1 -1
  107. package/lib/stdlib/item/node/image.d.ts +1 -1
  108. package/lib/stdlib/item/node/image.js +1 -1
  109. package/lib/stdlib/item/node/image.js.map +1 -1
  110. package/lib/stdlib/plugin/history/combo-command.js +2 -2
  111. package/lib/stdlib/plugin/history/combo-command.js.map +1 -1
  112. package/lib/stdlib/plugin/history/index.d.ts +10 -10
  113. package/lib/stdlib/plugin/history/index.js +14 -14
  114. package/lib/stdlib/plugin/history/index.js.map +1 -1
  115. package/lib/stdlib/plugin/history/item-data-command.js +4 -4
  116. package/lib/stdlib/plugin/history/item-data-command.js.map +1 -1
  117. package/lib/stdlib/plugin/history/layer-updated-command.js +2 -2
  118. package/lib/stdlib/plugin/history/layer-updated-command.js.map +1 -1
  119. package/lib/stdlib/plugin/history/state-updated-command.js +1 -1
  120. package/lib/stdlib/plugin/history/state-updated-command.js.map +1 -1
  121. package/lib/stdlib/plugin/history/visibility-updated-command.js +2 -2
  122. package/lib/stdlib/plugin/history/visibility-updated-command.js.map +1 -1
  123. package/lib/stdlib/plugin/index.d.ts +1 -0
  124. package/lib/stdlib/plugin/index.js +1 -0
  125. package/lib/stdlib/plugin/index.js.map +1 -1
  126. package/lib/stdlib/plugin/snapline/index.d.ts +163 -0
  127. package/lib/stdlib/plugin/snapline/index.js +1056 -0
  128. package/lib/stdlib/plugin/snapline/index.js.map +1 -0
  129. package/lib/stdlib/plugin/types.d.ts +1 -0
  130. package/lib/types/graph.d.ts +14 -14
  131. package/lib/types/hook.d.ts +6 -0
  132. package/lib/types/spec.d.ts +13 -0
  133. package/lib/util/bbox.d.ts +16 -1
  134. package/lib/util/bbox.js +32 -1
  135. package/lib/util/bbox.js.map +1 -1
  136. package/lib/util/shape.js +2 -2
  137. package/lib/util/shape.js.map +1 -1
  138. package/package.json +2 -2
  139. package/src/index.ts +1 -1
  140. package/src/item/edge.ts +4 -1
  141. package/src/item/item.ts +11 -6
  142. package/src/item/node.ts +10 -7
  143. package/src/runtime/controller/item.ts +212 -66
  144. package/src/runtime/graph.ts +91 -29
  145. package/src/stdlib/behavior/activate-relations.ts +2 -2
  146. package/src/stdlib/behavior/click-select.ts +1 -1
  147. package/src/stdlib/behavior/drag-canvas.ts +65 -27
  148. package/src/stdlib/behavior/drag-combo.ts +8 -8
  149. package/src/stdlib/behavior/drag-node.ts +10 -10
  150. package/src/stdlib/behavior/zoom-canvas.ts +60 -24
  151. package/src/stdlib/index.ts +10 -7
  152. package/src/stdlib/item/edge/base.ts +13 -5
  153. package/src/stdlib/item/node/base.ts +15 -14
  154. package/src/stdlib/item/node/image.ts +1 -1
  155. package/src/stdlib/plugin/history/combo-command.ts +2 -2
  156. package/src/stdlib/plugin/history/index.ts +14 -14
  157. package/src/stdlib/plugin/history/item-data-command.ts +4 -4
  158. package/src/stdlib/plugin/history/layer-updated-command.ts +2 -2
  159. package/src/stdlib/plugin/history/state-updated-command.ts +1 -1
  160. package/src/stdlib/plugin/history/visibility-updated-command.ts +2 -2
  161. package/src/stdlib/plugin/index.ts +1 -0
  162. package/src/stdlib/plugin/snapline/index.ts +1277 -0
  163. package/src/stdlib/plugin/types.ts +1 -0
  164. package/src/types/graph.ts +22 -17
  165. package/src/types/hook.ts +6 -0
  166. package/src/types/spec.ts +13 -0
  167. package/src/util/bbox.ts +38 -1
  168. package/src/util/shape.ts +2 -2
@@ -1,5 +1,6 @@
1
1
  import { ID, IG6GraphEvent } from 'types';
2
2
  import { Behavior } from '../../types/behavior';
3
+ import { isNumber } from '@antv/util';
3
4
 
4
5
  const VALID_TRIGGERS = ['wheel', 'upDownKeys'];
5
6
  export interface ZoomCanvasOptions {
@@ -56,7 +57,7 @@ export interface ZoomCanvasOptions {
56
57
  }
57
58
 
58
59
  const DEFAULT_OPTIONS: Required<ZoomCanvasOptions> = {
59
- enableOptimize: false,
60
+ enableOptimize: undefined,
60
61
  triggerOnItems: true,
61
62
  sensitivity: 2,
62
63
  trigger: 'wheel',
@@ -114,43 +115,78 @@ export class ZoomCanvas extends Behavior {
114
115
 
115
116
  private hideShapes() {
116
117
  const { graph } = this;
117
- if (this.options.enableOptimize) {
118
+ const { tileBehavior: graphBehaviorOptimize, tileBehaviorSize = 1000 } =
119
+ graph.getSpecification().optimize || {};
120
+ const optimize = this.options.enableOptimize || graphBehaviorOptimize;
121
+ const shouldOptimzie = isNumber(optimize)
122
+ ? graph.getAllNodesData().length > optimize
123
+ : optimize;
124
+ if (shouldOptimzie) {
118
125
  this.hiddenEdgeIds = graph
119
126
  .getAllEdgesData()
120
127
  .map((edge) => edge.id)
121
128
  .filter((id) => graph.getItemVisible(id) === true);
122
- // TODO
123
- graph.hideItem(this.hiddenEdgeIds, false);
124
129
  this.hiddenNodeIds = graph
125
130
  .getAllNodesData()
126
131
  .map((node) => node.id)
127
132
  .filter((id) => graph.getItemVisible(id) === true);
128
- // draw node's keyShapes on transient, and then hidden the real nodes;
129
- // this.hiddenNodeIds.forEach((id) => {
130
- // graph.drawTransient('node', id, {
131
- // onlyDrawKeyShape: true,
132
- // });
133
- // });
134
- // graph.hideItem(this.hiddenNodeIds, false);
133
+
134
+ let requestId;
135
+ const hiddenIds = [...this.hiddenNodeIds];
136
+ const sectionNum = Math.ceil(hiddenIds.length / tileBehaviorSize);
137
+ const sections = Array.from({ length: sectionNum }, (v, i) =>
138
+ hiddenIds.slice(
139
+ i * tileBehaviorSize,
140
+ i * tileBehaviorSize + tileBehaviorSize,
141
+ ),
142
+ );
143
+ const update = () => {
144
+ if (!sections.length) {
145
+ cancelAnimationFrame(requestId);
146
+ return;
147
+ }
148
+ const section = sections.shift();
149
+ graph.hideItem(section, false, true);
150
+ requestId = requestAnimationFrame(update);
151
+ };
152
+ graph.startHistoryBatch();
153
+ requestId = requestAnimationFrame(update);
154
+ graph.stopHistoryBatch();
135
155
  }
136
156
  }
137
157
 
138
158
  private endZoom() {
139
- const { graph, hiddenEdgeIds, hiddenNodeIds } = this;
140
- const { enableOptimize } = this.options;
159
+ const { graph, hiddenEdgeIds = [], hiddenNodeIds } = this;
160
+ const { tileBehavior: graphBehaviorOptimize, tileBehaviorSize = 1000 } =
161
+ graph.getSpecification().optimize || {};
162
+ const optimize = this.options.enableOptimize || graphBehaviorOptimize;
163
+ const shouldOptimzie = isNumber(optimize)
164
+ ? graph.getAllNodesData().length > optimize
165
+ : optimize;
141
166
  this.zooming = false;
142
- if (enableOptimize) {
143
- // restore hidden items
144
- if (hiddenEdgeIds) {
145
- graph.showItem(hiddenEdgeIds, false);
167
+ if (shouldOptimzie) {
168
+ if (hiddenNodeIds) {
169
+ let requestId;
170
+ const hiddenIds = [...hiddenNodeIds, ...hiddenEdgeIds];
171
+ const sectionNum = Math.ceil(hiddenIds.length / tileBehaviorSize);
172
+ const sections = Array.from({ length: sectionNum }, (v, i) =>
173
+ hiddenIds.slice(
174
+ i * tileBehaviorSize,
175
+ i * tileBehaviorSize + tileBehaviorSize,
176
+ ),
177
+ );
178
+ const update = () => {
179
+ if (!sections.length) {
180
+ cancelAnimationFrame(requestId);
181
+ return;
182
+ }
183
+ graph.showItem(sections.shift(), false);
184
+ requestId = requestAnimationFrame(update);
185
+ };
186
+ graph.executeWithNoStack(() => {
187
+ requestId = requestAnimationFrame(update);
188
+ });
146
189
  }
147
- // TODO
148
- // if (hiddenNodeIds) {
149
- // hiddenNodeIds.forEach((id) => {
150
- // graph.drawTransient('node', id, { action: 'remove' });
151
- // });
152
- // graph.showItem(hiddenNodeIds, false);
153
- // }
154
190
  }
155
191
  this.hiddenEdgeIds = [];
156
192
  this.hiddenNodeIds = [];
@@ -73,6 +73,7 @@ const {
73
73
  Legend,
74
74
  Toolbar,
75
75
  Timebar,
76
+ Snapline,
76
77
  } = Plugins;
77
78
 
78
79
  const {
@@ -206,13 +207,13 @@ const Extensions = {
206
207
  ValidateData,
207
208
  TransformV4Data,
208
209
  MapNodeSize,
209
- //themes
210
+ // themes
210
211
  LightTheme,
211
212
  DarkTheme,
212
- //themeSolvers
213
+ // themeSolvers
213
214
  SpecThemeSolver,
214
215
  SubjectThemeSolver,
215
- //layout
216
+ // layout
216
217
  ForceLayout,
217
218
  GridLayout,
218
219
  CircularLayout,
@@ -225,12 +226,12 @@ const Extensions = {
225
226
  ForceAtlas2Layout,
226
227
  DagreLayout,
227
228
  ComboCombinedLayout,
228
- //Hierarchy
229
+ // Hierarchy
229
230
  compactBox,
230
231
  dendrogram,
231
232
  indented,
232
233
  mindmap,
233
- //nodes
234
+ // nodes
234
235
  CircleNode,
235
236
  RectNode,
236
237
  DiamondNode,
@@ -252,7 +253,7 @@ const Extensions = {
252
253
  // combos
253
254
  CircleCombo,
254
255
  RectCombo,
255
- //behaviors
256
+ // behaviors
256
257
  BaseBehavior,
257
258
  ActivateRelations,
258
259
  BrushSelect,
@@ -268,7 +269,8 @@ const Extensions = {
268
269
  CollapseExpandCombo,
269
270
  DragNode,
270
271
  DragCombo,
271
- //plugins
272
+ ShortcutsCall,
273
+ // plugins
272
274
  BasePlugin,
273
275
  History,
274
276
  Toolbar,
@@ -280,6 +282,7 @@ const Extensions = {
280
282
  Legend,
281
283
  Timebar,
282
284
  Hull,
285
+ Snapline,
283
286
  };
284
287
 
285
288
  export default registery;
@@ -550,7 +550,11 @@ export abstract class BaseEdge {
550
550
  * @param shapeMap The shape map that contains all of the elements to show on the edge.
551
551
  * @param zoom The zoom level of the graph.
552
552
  */
553
- public onZoom = (shapeMap: EdgeShapeMap, zoom: number) => {
553
+ public onZoom = (
554
+ shapeMap: EdgeShapeMap,
555
+ zoom: number,
556
+ cacheHiddenShape = {},
557
+ ) => {
554
558
  // balance the size for label, badges
555
559
  this.balanceShapeSize(shapeMap, zoom);
556
560
 
@@ -574,7 +578,10 @@ export abstract class BaseEdge {
574
578
  // zoomLevel changed, from higher to lower, hide something
575
579
  if (firstRender) {
576
580
  for (let i = currentLevel + 1; i <= maxLevel; i++) {
577
- levelShapes[String(i)]?.forEach((id) => shapeMap[id]?.hide());
581
+ levelShapes[String(i)]?.forEach((id) => {
582
+ if (!shapeMap[id] || cacheHiddenShape[id]) return;
583
+ shapeMap[id]?.hide();
584
+ });
578
585
  }
579
586
  } else {
580
587
  for (let i = currentLevel + 1; i <= maxLevel; i++) {
@@ -586,7 +593,8 @@ export abstract class BaseEdge {
586
593
  } else if (currentLevel > previousLevel) {
587
594
  // zoomLevel changed, from lower to higher, show something
588
595
  for (let i = currentLevel; i >= minLevel; i--) {
589
- levelShapes[String(i)]?.forEach((id) =>
596
+ levelShapes[String(i)]?.forEach((id) => {
597
+ if (hiddenShape[id]) return;
590
598
  fadeIn(
591
599
  id,
592
600
  shapeMap[id],
@@ -594,8 +602,8 @@ export abstract class BaseEdge {
594
602
  this.mergedStyles[id.replace('Background', '')],
595
603
  hiddenShape,
596
604
  animateConfig,
597
- ),
598
- );
605
+ );
606
+ });
599
607
  }
600
608
  }
601
609
 
@@ -804,7 +804,11 @@ export abstract class BaseNode {
804
804
  * @param shapeMap The shape map that contains all of the elements to show on the node.
805
805
  * @param zoom The zoom level of the graph.
806
806
  */
807
- public onZoom = (shapeMap: NodeShapeMap | ComboShapeMap, zoom: number) => {
807
+ public onZoom = (
808
+ shapeMap: NodeShapeMap | ComboShapeMap,
809
+ zoom: number,
810
+ cacheHiddenShape = {},
811
+ ) => {
808
812
  // zoomLevel changed
809
813
  if (this.lodStrategy) {
810
814
  const { levels } = this.lodStrategy;
@@ -825,7 +829,7 @@ export abstract class BaseNode {
825
829
  // zoomLevel changed, from higher to lower, hide something
826
830
  for (let i = currentLevel + 1; i <= maxLevel; i++) {
827
831
  levelShapes[String(i)]?.forEach((id) => {
828
- if (!shapeMap[id]) return;
832
+ if (!shapeMap[id] || cacheHiddenShape[id]) return;
829
833
  shapeMap[id].hide();
830
834
  hiddenShape[id] = true;
831
835
  });
@@ -874,8 +878,7 @@ export abstract class BaseNode {
874
878
  const balanceRatio = 1 / zoom || 1;
875
879
  this.zoomCache.balanceRatio = balanceRatio;
876
880
  if (!labelShape || !labelShape.isVisible()) return;
877
- const { labelShape: labelStyle } = this.mergedStyles;
878
- const { position = 'bottom' } = labelStyle;
881
+ const { position = 'bottom' } = this.mergedStyles.labelShape;
879
882
 
880
883
  const keyShapeLocal = keyShape.getLocalBounds();
881
884
  if (zoom < 1) {
@@ -917,21 +920,20 @@ export abstract class BaseNode {
917
920
  const scaleTransform = `scale(${balanceRatio}, ${balanceRatio})`;
918
921
  labelShape.style.transform = `${oriTransform} ${scaleTransform}`;
919
922
  this.scaleTransformCache = scaleTransform;
920
- const wordWrapWidth = this.zoomCache.wordWrapWidth * zoom;
921
- labelShape.style.wordWrapWidth = wordWrapWidth;
923
+ labelShape.style.wordWrapWidth = this.zoomCache.wordWrapWidth * zoom;
922
924
 
923
925
  if (!labelBackgroundShape || !labelBackgroundShape.isVisible()) return;
924
926
 
925
- const { padding } = this.mergedStyles.labelBackgroundShape;
927
+ const [paddingTop, paddingRight, paddingBottom, paddingLeft] = this
928
+ .mergedStyles.labelBackgroundShape.padding as number[];
929
+ const sidePadding = paddingRight + paddingLeft;
926
930
  const { width, height, x, y } = labelBackgroundShape.attributes;
927
- const [paddingTop, paddingRight, paddingBottom, paddingLeft] =
928
- padding as number[];
929
931
 
930
932
  switch (position) {
931
933
  case 'top':
932
934
  // if it is zoom-out, do not scale the gap between keyShape and labelShape, differentiate from zoom-in by adjusting transformOrigin
933
935
  labelBackgroundShape.style.transformOrigin = `${
934
- paddingLeft + (width - paddingLeft - paddingRight) / 2
936
+ paddingLeft + (width - sidePadding) / 2
935
937
  } ${zoom < 1 ? height - paddingBottom : keyShapeLocal.min[1] - y}`;
936
938
  break;
937
939
  case 'left':
@@ -946,7 +948,7 @@ export abstract class BaseNode {
946
948
  break;
947
949
  case 'bottom':
948
950
  labelBackgroundShape.style.transformOrigin = `${
949
- paddingLeft + (width - paddingLeft - paddingRight) / 2
951
+ paddingLeft + (width - sidePadding) / 2
950
952
  } ${
951
953
  zoom < 1
952
954
  ? paddingTop + (height - paddingTop - paddingBottom) / 2
@@ -956,14 +958,13 @@ export abstract class BaseNode {
956
958
  default:
957
959
  // center
958
960
  labelBackgroundShape.style.transformOrigin = `${
959
- paddingLeft + (width - paddingLeft - paddingRight) / 2
961
+ paddingLeft + (width - sidePadding) / 2
960
962
  } ${paddingTop + (height - paddingTop - paddingBottom) / 2}`;
961
963
  }
962
964
 
963
965
  const { labelShapeGeometry: labelBBox } = this.boundsCache;
964
966
  const labelWidth = labelBBox.max[0] - labelBBox.min[0];
965
- const xAxistRatio =
966
- (labelWidth * balanceRatio + paddingLeft + paddingRight) / width;
967
+ const xAxistRatio = (labelWidth * balanceRatio + sidePadding) / width;
967
968
 
968
969
  labelBackgroundShape.style.transform = `scale(${xAxistRatio}, ${balanceRatio})`;
969
970
  }
@@ -7,9 +7,9 @@ import {
7
7
  NodeShapeStyles,
8
8
  } from '../../../types/node';
9
9
  import { convertToNumber } from '../../../util/type';
10
- import { BaseNode } from './base';
11
10
  import { ComboModelData, ComboShapeMap } from '../../../types/combo';
12
11
  import { ShapeTagMap } from '../../../util/shape';
12
+ import { BaseNode } from './base';
13
13
 
14
14
  export class ImageNode extends BaseNode {
15
15
  override defaultStyles = {
@@ -11,7 +11,7 @@ export class ComboCommand implements Command {
11
11
  }
12
12
 
13
13
  undo(graph: IGraph) {
14
- graph.executeWithoutStacking(() => {
14
+ graph.executeWithNoStack(() => {
15
15
  this.action === 'expandCombo'
16
16
  ? graph.collapseCombo(this.ids)
17
17
  : graph.expandCombo(this.ids);
@@ -19,7 +19,7 @@ export class ComboCommand implements Command {
19
19
  }
20
20
 
21
21
  redo(graph: IGraph) {
22
- graph.executeWithoutStacking(() => {
22
+ graph.executeWithNoStack(() => {
23
23
  this.action === 'collapseCombo'
24
24
  ? graph.collapseCombo(this.ids)
25
25
  : graph.expandCombo(this.ids);
@@ -200,7 +200,7 @@ export class History extends Base {
200
200
  /**
201
201
  * Pause stacking operations.
202
202
  */
203
- pauseStacking(): void {
203
+ pauseStack(): void {
204
204
  this.withoutStackingCounter++;
205
205
 
206
206
  if (this.withoutStackingCounter === 1) {
@@ -212,7 +212,7 @@ export class History extends Base {
212
212
  /**
213
213
  * Resume stacking operations.
214
214
  */
215
- resumeStacking(): void {
215
+ resumeStack(): void {
216
216
  if (this.withoutStackingCounter > 0) {
217
217
  this.withoutStackingCounter--;
218
218
  }
@@ -260,14 +260,14 @@ export class History extends Base {
260
260
  }
261
261
 
262
262
  /**
263
- * Begin a batch operation.
264
- * Any operations performed between `startBatch` and `stopBatch` are grouped together.
263
+ * Begin a historyBatch operation.
264
+ * Any operations performed between `startHistoryBatch` and `stopHistoryBatch` are grouped together.
265
265
  * treated as a single operation when undoing or redoing.
266
266
  */
267
- public startBatch() {
267
+ public startHistoryBatch() {
268
268
  if (this.isBatching) {
269
269
  throw new Error(
270
- 'Ensure that batch processing is stopped before starting.',
270
+ 'Ensure that historyBatch processing is stopped before starting.',
271
271
  );
272
272
  }
273
273
  this.initBatchCommands();
@@ -275,14 +275,14 @@ export class History extends Base {
275
275
  }
276
276
 
277
277
  /**
278
- * End a batch operation.
279
- * Any operations performed between `startBatch` and `stopBatch` are grouped together.
278
+ * End a historyBatch operation.
279
+ * Any operations performed between `startHistoryBatch` and `stopHistoryBatch` are grouped together.
280
280
  * treated as a single operation when undoing or redoing.
281
281
  */
282
- public stopBatch() {
282
+ public stopHistoryBatch() {
283
283
  if (!this.isBatching) {
284
284
  throw new Error(
285
- 'Ensure that batch processing is started before stopping.',
285
+ 'Ensure that historyBatch processing is started before stopping.',
286
286
  );
287
287
  }
288
288
  this.push(this.batchCommands);
@@ -290,13 +290,13 @@ export class History extends Base {
290
290
  }
291
291
 
292
292
  /**
293
- * Execute the provided function in a batch mode
293
+ * Execute the provided function in a historyBatch mode
294
294
  * @param callback
295
295
  */
296
- public batch(callback) {
297
- this.startBatch();
296
+ public historyBatch(callback) {
297
+ this.startHistoryBatch();
298
298
  callback();
299
- this.stopBatch();
299
+ this.stopHistoryBatch();
300
300
  }
301
301
 
302
302
  public getEvents() {
@@ -26,14 +26,14 @@ export class ItemDataCommand implements Command {
26
26
 
27
27
  private removeChangedData(graph) {
28
28
  const ids = this.changes.map((data) => data.value?.id).filter(Boolean);
29
- graph.executeWithoutStacking(() => {
29
+ graph.executeWithNoStack(() => {
30
30
  graph.removeData(this.type, ids);
31
31
  });
32
32
  }
33
33
 
34
34
  private addChangedData(graph) {
35
35
  const models = this.changes.map((data) => data.value).filter(Boolean);
36
- graph.executeWithoutStacking(() => {
36
+ graph.executeWithNoStack(() => {
37
37
  graph.addData(this.type, models);
38
38
  });
39
39
  }
@@ -61,13 +61,13 @@ export class ItemDataCommand implements Command {
61
61
  });
62
62
  }
63
63
 
64
- graph.pauseStacking();
64
+ graph.pauseStack();
65
65
  if (onlyMove) {
66
66
  graph.updatePosition(this.type, models, this.upsertAncestors);
67
67
  } else {
68
68
  graph.updateData(this.type, models);
69
69
  }
70
- graph.resumeStacking();
70
+ graph.resumeStack();
71
71
  }
72
72
 
73
73
  undo(graph: IGraph) {
@@ -11,7 +11,7 @@ export class LayerUpdatedCommand implements Command {
11
11
  }
12
12
 
13
13
  undo(graph: IGraph) {
14
- graph.executeWithoutStacking(() => {
14
+ graph.executeWithNoStack(() => {
15
15
  this.action === 'front'
16
16
  ? graph.backItem(this.ids)
17
17
  : graph.frontItem(this.ids);
@@ -19,7 +19,7 @@ export class LayerUpdatedCommand implements Command {
19
19
  }
20
20
 
21
21
  redo(graph: IGraph) {
22
- graph.executeWithoutStacking(() => {
22
+ graph.executeWithNoStack(() => {
23
23
  this.action === 'front'
24
24
  ? graph.frontItem(this.ids)
25
25
  : graph.backItem(this.ids);
@@ -20,7 +20,7 @@ export class StateUpdatedCommand implements Command {
20
20
  private updateItemsStates(graph, stateOptions) {
21
21
  stateOptions?.map((option) => {
22
22
  const { ids, states, value } = option;
23
- graph.executeWithoutStacking(() => {
23
+ graph.executeWithNoStack(() => {
24
24
  graph.setItemState(ids, states, value);
25
25
  });
26
26
  });
@@ -20,13 +20,13 @@ export class VisibilityUpdatedCommand implements Command {
20
20
  }
21
21
 
22
22
  private toggleItemsVisible(graph: IGraph, values) {
23
- graph.pauseStacking();
23
+ graph.pauseStack();
24
24
  each(values, (value) =>
25
25
  value.visible
26
26
  ? graph.showItem(value.ids, this.disableAnimate)
27
27
  : graph.hideItem(value.ids, this.disableAnimate),
28
28
  );
29
- graph.resumeStacking();
29
+ graph.resumeStack();
30
30
  }
31
31
 
32
32
  undo(graph: IGraph) {
@@ -7,3 +7,4 @@ export * from './minimap';
7
7
  export * from './toolbar';
8
8
  export * from './tooltip';
9
9
  export * from './timebar';
10
+ export * from './snapline';