@antv/g6 5.0.0-beta.25 → 5.0.0-beta.27
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/dist/g6.min.js +2 -2
- package/esm/constant/shape.d.ts +1 -1
- package/esm/index.d.ts +3 -1
- package/esm/index.js +1 -1
- package/esm/item/combo.d.ts +6 -4
- package/esm/item/combo.js +10 -3
- package/esm/item/combo.js.map +1 -1
- package/esm/item/edge.d.ts +12 -4
- package/esm/item/edge.js +100 -17
- package/esm/item/edge.js.map +1 -1
- package/esm/item/item.d.ts +18 -8
- package/esm/item/item.js +121 -62
- package/esm/item/item.js.map +1 -1
- package/esm/item/node.d.ts +10 -4
- package/esm/item/node.js +92 -8
- package/esm/item/node.js.map +1 -1
- package/esm/runtime/controller/data.d.ts +5 -1
- package/esm/runtime/controller/data.js +38 -1
- package/esm/runtime/controller/data.js.map +1 -1
- package/esm/runtime/controller/index.d.ts +1 -1
- package/esm/runtime/controller/index.js +1 -1
- package/esm/runtime/controller/index.js.map +1 -1
- package/esm/runtime/controller/item.d.ts +22 -11
- package/esm/runtime/controller/item.js +241 -96
- package/esm/runtime/controller/item.js.map +1 -1
- package/esm/runtime/controller/layout.d.ts +3 -0
- package/esm/runtime/controller/layout.js +178 -98
- package/esm/runtime/controller/layout.js.map +1 -1
- package/esm/runtime/controller/plugin.d.ts +3 -0
- package/esm/runtime/controller/plugin.js +66 -24
- package/esm/runtime/controller/plugin.js.map +1 -1
- package/esm/runtime/controller/viewport.js +9 -2
- package/esm/runtime/controller/viewport.js.map +1 -1
- package/esm/runtime/graph.d.ts +57 -26
- package/esm/runtime/graph.js +263 -139
- package/esm/runtime/graph.js.map +1 -1
- package/esm/stdlib/behavior/click-select.js +9 -3
- package/esm/stdlib/behavior/click-select.js.map +1 -1
- package/esm/stdlib/behavior/drag-canvas.js +6 -3
- package/esm/stdlib/behavior/drag-canvas.js.map +1 -1
- package/esm/stdlib/behavior/drag-combo.js +8 -8
- package/esm/stdlib/behavior/drag-combo.js.map +1 -1
- package/esm/stdlib/behavior/drag-node.d.ts +4 -0
- package/esm/stdlib/behavior/drag-node.js +121 -27
- package/esm/stdlib/behavior/drag-node.js.map +1 -1
- package/esm/stdlib/behavior/scroll-canvas.js +3 -3
- package/esm/stdlib/behavior/scroll-canvas.js.map +1 -1
- package/esm/stdlib/behavior/zoom-canvas.js +3 -3
- package/esm/stdlib/behavior/zoom-canvas.js.map +1 -1
- package/esm/stdlib/data/mapNodeSize.js +2 -2
- package/esm/stdlib/data/mapNodeSize.js.map +1 -1
- package/esm/stdlib/data/validateData.js +2 -2
- package/esm/stdlib/data/validateData.js.map +1 -1
- package/esm/stdlib/index.d.ts +2 -0
- package/esm/stdlib/index.js +3 -1
- package/esm/stdlib/index.js.map +1 -1
- package/esm/stdlib/item/edge/base.d.ts +2 -11
- package/esm/stdlib/item/edge/base.js +12 -105
- package/esm/stdlib/item/edge/base.js.map +1 -1
- package/esm/stdlib/item/node/base.d.ts +2 -20
- package/esm/stdlib/item/node/base.js +10 -150
- package/esm/stdlib/item/node/base.js.map +1 -1
- package/esm/stdlib/plugin/edgeFilterLens/index.js +2 -2
- package/esm/stdlib/plugin/edgeFilterLens/index.js.map +1 -1
- package/esm/stdlib/plugin/fisheye/index.js +3 -2
- package/esm/stdlib/plugin/fisheye/index.js.map +1 -1
- package/esm/stdlib/plugin/history/visibility-updated-command.js +2 -2
- package/esm/stdlib/plugin/history/visibility-updated-command.js.map +1 -1
- package/esm/stdlib/plugin/hull/index.d.ts +1 -1
- package/esm/stdlib/plugin/index.d.ts +1 -0
- package/esm/stdlib/plugin/index.js +1 -0
- package/esm/stdlib/plugin/index.js.map +1 -1
- package/esm/stdlib/plugin/lodController/index.d.ts +73 -0
- package/esm/stdlib/plugin/lodController/index.js +556 -0
- package/esm/stdlib/plugin/lodController/index.js.map +1 -0
- package/esm/stdlib/plugin/menu/index.js +2 -1
- package/esm/stdlib/plugin/menu/index.js.map +1 -1
- package/esm/stdlib/plugin/minimap/index.js +12 -14
- package/esm/stdlib/plugin/minimap/index.js.map +1 -1
- package/esm/stdlib/plugin/toolbar/index.d.ts +2 -2
- package/esm/stdlib/plugin/toolbar/index.js +27 -29
- package/esm/stdlib/plugin/toolbar/index.js.map +1 -1
- package/esm/stdlib/theme/dark.js +32 -35
- package/esm/stdlib/theme/dark.js.map +1 -1
- package/esm/stdlib/theme/light.js +27 -30
- package/esm/stdlib/theme/light.js.map +1 -1
- package/esm/stdlib/themeSolver/spec.js +2 -2
- package/esm/stdlib/themeSolver/spec.js.map +1 -1
- package/esm/types/animate.d.ts +1 -1
- package/esm/types/combo.d.ts +2 -2
- package/esm/types/edge.d.ts +2 -2
- package/esm/types/graph.d.ts +62 -43
- package/esm/types/hook.d.ts +5 -0
- package/esm/types/item.d.ts +9 -15
- package/esm/types/layout.d.ts +7 -2
- package/esm/types/layout.js.map +1 -1
- package/esm/types/node.d.ts +3 -2
- package/esm/types/plugin.d.ts +1 -0
- package/esm/types/plugin.js +1 -0
- package/esm/types/plugin.js.map +1 -1
- package/esm/types/spec.d.ts +1 -0
- package/esm/types/theme.d.ts +7 -7
- package/esm/util/animate.d.ts +7 -2
- package/esm/util/animate.js +40 -23
- package/esm/util/animate.js.map +1 -1
- package/esm/util/bbox.d.ts +7 -1
- package/esm/util/bbox.js +16 -0
- package/esm/util/bbox.js.map +1 -1
- package/esm/util/data.d.ts +7 -1
- package/esm/util/data.js +17 -5
- package/esm/util/data.js.map +1 -1
- package/esm/util/dom.js +5 -5
- package/esm/util/dom.js.map +1 -1
- package/esm/util/item.d.ts +1 -1
- package/esm/util/item.js +8 -8
- package/esm/util/item.js.map +1 -1
- package/esm/util/mapper.js +1 -1
- package/esm/util/mapper.js.map +1 -1
- package/esm/util/path.d.ts +6 -1
- package/esm/util/path.js +72 -1
- package/esm/util/path.js.map +1 -1
- package/esm/util/polyline.d.ts +10 -0
- package/esm/util/polyline.js +22 -17
- package/esm/util/polyline.js.map +1 -1
- package/esm/util/router.d.ts +1 -1
- package/esm/util/router.js +19 -18
- package/esm/util/router.js.map +1 -1
- package/esm/util/shape.d.ts +1 -1
- package/esm/util/shape.js +28 -13
- package/esm/util/shape.js.map +1 -1
- package/esm/util/zoom.d.ts +5 -8
- package/esm/util/zoom.js +15 -20
- package/esm/util/zoom.js.map +1 -1
- package/lib/constant/shape.d.ts +1 -1
- package/lib/index.d.ts +3 -1
- package/lib/index.js +1 -1
- package/lib/item/combo.d.ts +6 -4
- package/lib/item/combo.js +10 -3
- package/lib/item/combo.js.map +1 -1
- package/lib/item/edge.d.ts +12 -4
- package/lib/item/edge.js +99 -16
- package/lib/item/edge.js.map +1 -1
- package/lib/item/item.d.ts +18 -8
- package/lib/item/item.js +119 -60
- package/lib/item/item.js.map +1 -1
- package/lib/item/node.d.ts +10 -4
- package/lib/item/node.js +92 -8
- package/lib/item/node.js.map +1 -1
- package/lib/runtime/controller/data.d.ts +5 -1
- package/lib/runtime/controller/data.js +38 -1
- package/lib/runtime/controller/data.js.map +1 -1
- package/lib/runtime/controller/index.d.ts +1 -1
- package/lib/runtime/controller/index.js +1 -1
- package/lib/runtime/controller/index.js.map +1 -1
- package/lib/runtime/controller/item.d.ts +22 -11
- package/lib/runtime/controller/item.js +238 -93
- package/lib/runtime/controller/item.js.map +1 -1
- package/lib/runtime/controller/layout.d.ts +3 -0
- package/lib/runtime/controller/layout.js +178 -98
- package/lib/runtime/controller/layout.js.map +1 -1
- package/lib/runtime/controller/plugin.d.ts +3 -0
- package/lib/runtime/controller/plugin.js +66 -24
- package/lib/runtime/controller/plugin.js.map +1 -1
- package/lib/runtime/controller/viewport.js +9 -2
- package/lib/runtime/controller/viewport.js.map +1 -1
- package/lib/runtime/graph.d.ts +57 -26
- package/lib/runtime/graph.js +263 -139
- package/lib/runtime/graph.js.map +1 -1
- package/lib/stdlib/behavior/click-select.js +9 -3
- package/lib/stdlib/behavior/click-select.js.map +1 -1
- package/lib/stdlib/behavior/drag-canvas.js +6 -3
- package/lib/stdlib/behavior/drag-canvas.js.map +1 -1
- package/lib/stdlib/behavior/drag-combo.js +8 -8
- package/lib/stdlib/behavior/drag-combo.js.map +1 -1
- package/lib/stdlib/behavior/drag-node.d.ts +4 -0
- package/lib/stdlib/behavior/drag-node.js +121 -27
- package/lib/stdlib/behavior/drag-node.js.map +1 -1
- package/lib/stdlib/behavior/scroll-canvas.js +3 -3
- package/lib/stdlib/behavior/scroll-canvas.js.map +1 -1
- package/lib/stdlib/behavior/zoom-canvas.js +3 -3
- package/lib/stdlib/behavior/zoom-canvas.js.map +1 -1
- package/lib/stdlib/data/mapNodeSize.js +2 -2
- package/lib/stdlib/data/mapNodeSize.js.map +1 -1
- package/lib/stdlib/data/validateData.js +2 -2
- package/lib/stdlib/data/validateData.js.map +1 -1
- package/lib/stdlib/index.d.ts +2 -0
- package/lib/stdlib/index.js +3 -1
- package/lib/stdlib/index.js.map +1 -1
- package/lib/stdlib/item/edge/base.d.ts +2 -11
- package/lib/stdlib/item/edge/base.js +12 -105
- package/lib/stdlib/item/edge/base.js.map +1 -1
- package/lib/stdlib/item/node/base.d.ts +2 -20
- package/lib/stdlib/item/node/base.js +10 -150
- package/lib/stdlib/item/node/base.js.map +1 -1
- package/lib/stdlib/plugin/edgeFilterLens/index.js +2 -2
- package/lib/stdlib/plugin/edgeFilterLens/index.js.map +1 -1
- package/lib/stdlib/plugin/fisheye/index.js +2 -1
- package/lib/stdlib/plugin/fisheye/index.js.map +1 -1
- package/lib/stdlib/plugin/history/visibility-updated-command.js +2 -2
- package/lib/stdlib/plugin/history/visibility-updated-command.js.map +1 -1
- package/lib/stdlib/plugin/hull/index.d.ts +1 -1
- package/lib/stdlib/plugin/index.d.ts +1 -0
- package/lib/stdlib/plugin/index.js +1 -0
- package/lib/stdlib/plugin/index.js.map +1 -1
- package/lib/stdlib/plugin/lodController/index.d.ts +73 -0
- package/lib/stdlib/plugin/lodController/index.js +560 -0
- package/lib/stdlib/plugin/lodController/index.js.map +1 -0
- package/lib/stdlib/plugin/menu/index.js +2 -1
- package/lib/stdlib/plugin/menu/index.js.map +1 -1
- package/lib/stdlib/plugin/minimap/index.js +12 -14
- package/lib/stdlib/plugin/minimap/index.js.map +1 -1
- package/lib/stdlib/plugin/toolbar/index.d.ts +2 -2
- package/lib/stdlib/plugin/toolbar/index.js +27 -29
- package/lib/stdlib/plugin/toolbar/index.js.map +1 -1
- package/lib/stdlib/theme/dark.js +32 -35
- package/lib/stdlib/theme/dark.js.map +1 -1
- package/lib/stdlib/theme/light.js +27 -30
- package/lib/stdlib/theme/light.js.map +1 -1
- package/lib/stdlib/themeSolver/spec.js +2 -2
- package/lib/stdlib/themeSolver/spec.js.map +1 -1
- package/lib/types/animate.d.ts +1 -1
- package/lib/types/combo.d.ts +2 -2
- package/lib/types/edge.d.ts +2 -2
- package/lib/types/graph.d.ts +62 -43
- package/lib/types/hook.d.ts +5 -0
- package/lib/types/item.d.ts +9 -15
- package/lib/types/layout.d.ts +7 -2
- package/lib/types/layout.js.map +1 -1
- package/lib/types/node.d.ts +3 -2
- package/lib/types/plugin.d.ts +1 -0
- package/lib/types/plugin.js +1 -0
- package/lib/types/plugin.js.map +1 -1
- package/lib/types/spec.d.ts +1 -0
- package/lib/types/theme.d.ts +7 -7
- package/lib/util/animate.d.ts +7 -2
- package/lib/util/animate.js +40 -23
- package/lib/util/animate.js.map +1 -1
- package/lib/util/bbox.d.ts +7 -1
- package/lib/util/bbox.js +18 -1
- package/lib/util/bbox.js.map +1 -1
- package/lib/util/data.d.ts +7 -1
- package/lib/util/data.js +19 -6
- package/lib/util/data.js.map +1 -1
- package/lib/util/dom.js +5 -5
- package/lib/util/dom.js.map +1 -1
- package/lib/util/item.d.ts +1 -1
- package/lib/util/item.js +8 -8
- package/lib/util/item.js.map +1 -1
- package/lib/util/mapper.js +1 -1
- package/lib/util/mapper.js.map +1 -1
- package/lib/util/path.d.ts +6 -1
- package/lib/util/path.js +72 -1
- package/lib/util/path.js.map +1 -1
- package/lib/util/polyline.d.ts +10 -0
- package/lib/util/polyline.js +25 -18
- package/lib/util/polyline.js.map +1 -1
- package/lib/util/router.d.ts +1 -1
- package/lib/util/router.js +19 -18
- package/lib/util/router.js.map +1 -1
- package/lib/util/shape.d.ts +1 -1
- package/lib/util/shape.js +27 -12
- package/lib/util/shape.js.map +1 -1
- package/lib/util/zoom.d.ts +5 -8
- package/lib/util/zoom.js +17 -22
- package/lib/util/zoom.js.map +1 -1
- package/package.json +1 -1
- package/src/index.ts +1 -1
- package/src/item/combo.ts +13 -5
- package/src/item/edge.ts +126 -17
- package/src/item/item.ts +140 -57
- package/src/item/node.ts +109 -12
- package/src/runtime/controller/data.ts +64 -3
- package/src/runtime/controller/index.ts +1 -1
- package/src/runtime/controller/item.ts +321 -135
- package/src/runtime/controller/layout.ts +254 -113
- package/src/runtime/controller/plugin.ts +86 -33
- package/src/runtime/controller/viewport.ts +8 -2
- package/src/runtime/graph.ts +383 -158
- package/src/stdlib/behavior/click-select.ts +8 -3
- package/src/stdlib/behavior/drag-canvas.ts +6 -3
- package/src/stdlib/behavior/drag-combo.ts +8 -8
- package/src/stdlib/behavior/drag-node.ts +165 -50
- package/src/stdlib/behavior/scroll-canvas.ts +3 -3
- package/src/stdlib/behavior/zoom-canvas.ts +3 -3
- package/src/stdlib/data/mapNodeSize.ts +2 -2
- package/src/stdlib/data/validateData.ts +2 -2
- package/src/stdlib/index.ts +3 -0
- package/src/stdlib/item/edge/base.ts +15 -139
- package/src/stdlib/item/node/base.ts +20 -215
- package/src/stdlib/plugin/edgeFilterLens/index.ts +2 -2
- package/src/stdlib/plugin/fisheye/index.ts +3 -2
- package/src/stdlib/plugin/history/visibility-updated-command.ts +2 -2
- package/src/stdlib/plugin/index.ts +1 -0
- package/src/stdlib/plugin/lodController/index.ts +602 -0
- package/src/stdlib/plugin/menu/index.ts +1 -1
- package/src/stdlib/plugin/minimap/index.ts +12 -14
- package/src/stdlib/plugin/toolbar/index.ts +29 -31
- package/src/stdlib/theme/dark.ts +32 -34
- package/src/stdlib/theme/light.ts +27 -29
- package/src/stdlib/themeSolver/spec.ts +2 -2
- package/src/types/animate.ts +1 -1
- package/src/types/combo.ts +2 -2
- package/src/types/edge.ts +2 -2
- package/src/types/graph.ts +65 -53
- package/src/types/hook.ts +5 -0
- package/src/types/item.ts +8 -14
- package/src/types/layout.ts +20 -15
- package/src/types/node.ts +3 -2
- package/src/types/plugin.ts +2 -0
- package/src/types/spec.ts +1 -0
- package/src/types/theme.ts +7 -7
- package/src/util/animate.ts +104 -75
- package/src/util/bbox.ts +26 -1
- package/src/util/data.ts +15 -6
- package/src/util/dom.ts +6 -6
- package/src/util/item.ts +15 -1
- package/src/util/mapper.ts +1 -1
- package/src/util/path.ts +72 -2
- package/src/util/polyline.ts +30 -23
- package/src/util/router.ts +21 -19
- package/src/util/shape.ts +27 -12
- package/src/util/zoom.ts +19 -25
- package/esm/runtime/controller/extension.d.ts +0 -9
- package/esm/runtime/controller/extension.js +0 -11
- package/esm/runtime/controller/extension.js.map +0 -1
- package/lib/runtime/controller/extension.d.ts +0 -9
- package/lib/runtime/controller/extension.js +0 -15
- package/lib/runtime/controller/extension.js.map +0 -1
- package/src/runtime/controller/extension.ts +0 -14
package/src/util/animate.ts
CHANGED
|
@@ -6,10 +6,11 @@ import {
|
|
|
6
6
|
Path,
|
|
7
7
|
Polyline,
|
|
8
8
|
} from '@antv/g';
|
|
9
|
+
import { isString, uniq } from '@antv/util';
|
|
9
10
|
import { AnimateTiming, IAnimate, IAnimates } from '../types/animate';
|
|
10
11
|
import { ItemShapeStyles, ShapeStyle } from '../types/item';
|
|
11
12
|
import { isArrayOverlap, replaceElements } from './array';
|
|
12
|
-
import {
|
|
13
|
+
import { cloneJSON } from './data';
|
|
13
14
|
|
|
14
15
|
/**
|
|
15
16
|
* Initial(timing = show) shape animation start from init shape styles, and end to the shape's style config.
|
|
@@ -45,6 +46,7 @@ export const getShapeAnimateBeginStyles = (shape) => {
|
|
|
45
46
|
opacity: 0,
|
|
46
47
|
strokeOpacity: 0,
|
|
47
48
|
offsetDistance: 0,
|
|
49
|
+
fill: '#000',
|
|
48
50
|
};
|
|
49
51
|
}
|
|
50
52
|
return {
|
|
@@ -75,7 +77,6 @@ export const DEFAULT_ANIMATE_CFG = {
|
|
|
75
77
|
duration: 500,
|
|
76
78
|
easing: 'cubic-bezier(0.250, 0.460, 0.450, 0.940)',
|
|
77
79
|
iterations: 1,
|
|
78
|
-
delay: 1000,
|
|
79
80
|
fill: 'both',
|
|
80
81
|
},
|
|
81
82
|
show: {
|
|
@@ -151,7 +152,8 @@ const groupTimingAnimates = (
|
|
|
151
152
|
*/
|
|
152
153
|
const runAnimateGroupOnShapes = (
|
|
153
154
|
shapeMap: { [shapeId: string]: DisplayObject },
|
|
154
|
-
|
|
155
|
+
shapeIds: string[] = undefined,
|
|
156
|
+
groups: Group[],
|
|
155
157
|
timingAnimates: IAnimate[],
|
|
156
158
|
targetStylesMap: ItemShapeStyles,
|
|
157
159
|
timing: AnimateTiming,
|
|
@@ -163,80 +165,104 @@ const runAnimateGroupOnShapes = (
|
|
|
163
165
|
let maxDurationIdx = -1;
|
|
164
166
|
let hasCanceled = canceled;
|
|
165
167
|
const isOut = timing === 'buildOut' || timing === 'hide';
|
|
166
|
-
const
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
...
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
168
|
+
const shapeIdsToAnimate = shapeIds ? shapeIds : Object.keys(shapeMap);
|
|
169
|
+
const animations = timingAnimates
|
|
170
|
+
.map((animateOptions: any) => {
|
|
171
|
+
const { fields, shapeId, order, states, ...animateCfg } = animateOptions;
|
|
172
|
+
const animateConfig = {
|
|
173
|
+
...DEFAULT_ANIMATE_CFG[timing],
|
|
174
|
+
...animateCfg,
|
|
175
|
+
};
|
|
176
|
+
const { iterations } = animateConfig;
|
|
177
|
+
if (iterations === Infinity && animateCfg.fill == undefined) {
|
|
178
|
+
animateConfig.fill = 'auto';
|
|
179
|
+
}
|
|
173
180
|
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
});
|
|
184
|
-
const targetStyle =
|
|
185
|
-
targetStylesMap.group || GROUP_ANIMATE_STYLES[isOut ? 0 : 1];
|
|
186
|
-
if (hasCanceled) {
|
|
187
|
-
Object.keys(targetStyle).forEach((key) => {
|
|
188
|
-
group.style[key] = targetStyle[key];
|
|
181
|
+
let animates = [];
|
|
182
|
+
if (!shapeId || shapeId === 'group') {
|
|
183
|
+
// animate on group
|
|
184
|
+
const usingFields = [];
|
|
185
|
+
let hasOpacity = false;
|
|
186
|
+
fields?.forEach((field) => {
|
|
187
|
+
if (field === 'size') usingFields.push('transform');
|
|
188
|
+
else if (field !== 'opacity') usingFields.push(field);
|
|
189
|
+
else hasOpacity = true;
|
|
189
190
|
});
|
|
190
|
-
} else {
|
|
191
|
-
if (hasOpacity) {
|
|
192
|
-
// opacity on group, animate on all shapes
|
|
193
|
-
Object.keys(shapeMap).forEach((shapeId) => {
|
|
194
|
-
const { opacity: targetOpaicty = 1 } =
|
|
195
|
-
targetStylesMap[shapeId] ||
|
|
196
|
-
targetStylesMap.otherShapes?.[shapeId] ||
|
|
197
|
-
{};
|
|
198
|
-
animation = runAnimateOnShape(
|
|
199
|
-
shapeMap[shapeId],
|
|
200
|
-
['opacity'],
|
|
201
|
-
{ opacity: targetOpaicty },
|
|
202
|
-
getShapeAnimateBeginStyles(shapeMap[shapeId]),
|
|
203
|
-
animateConfig,
|
|
204
|
-
);
|
|
205
|
-
});
|
|
206
|
-
}
|
|
207
|
-
if (usingFields.length) {
|
|
208
|
-
animation = runAnimateOnShape(
|
|
209
|
-
group,
|
|
210
|
-
usingFields,
|
|
211
|
-
targetStyle,
|
|
212
|
-
GROUP_ANIMATE_STYLES[isOut ? 1 : 0],
|
|
213
|
-
animateConfig,
|
|
214
|
-
);
|
|
215
|
-
}
|
|
216
|
-
}
|
|
217
|
-
} else {
|
|
218
|
-
const shape = shapeMap[shapeId];
|
|
219
|
-
if (shape && shape.style.display !== 'none') {
|
|
220
191
|
const targetStyle =
|
|
221
|
-
targetStylesMap[
|
|
222
|
-
targetStylesMap.otherShapes?.[shapeId] ||
|
|
223
|
-
{};
|
|
192
|
+
targetStylesMap.group || GROUP_ANIMATE_STYLES[isOut ? 0 : 1];
|
|
224
193
|
if (hasCanceled) {
|
|
225
194
|
Object.keys(targetStyle).forEach((key) => {
|
|
226
|
-
|
|
195
|
+
groups.forEach((group) => (group.style[key] = targetStyle[key]));
|
|
227
196
|
});
|
|
228
197
|
} else {
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
198
|
+
if (hasOpacity) {
|
|
199
|
+
// opacity on group, animate on all shapes
|
|
200
|
+
shapeIdsToAnimate.forEach((sid) => {
|
|
201
|
+
if (!shapeMap[sid]) return;
|
|
202
|
+
const { opacity: targetOpacity = isOut ? 0 : 1 } =
|
|
203
|
+
targetStylesMap[sid] ||
|
|
204
|
+
targetStylesMap.otherShapes?.[sid] ||
|
|
205
|
+
{};
|
|
206
|
+
animates.push(
|
|
207
|
+
runAnimateOnShape(
|
|
208
|
+
shapeMap[sid],
|
|
209
|
+
['opacity'],
|
|
210
|
+
{ opacity: targetOpacity },
|
|
211
|
+
getShapeAnimateBeginStyles(shapeMap[sid]),
|
|
212
|
+
animateConfig,
|
|
213
|
+
),
|
|
214
|
+
);
|
|
215
|
+
});
|
|
216
|
+
}
|
|
217
|
+
if (usingFields.length) {
|
|
218
|
+
animates = animates.concat(
|
|
219
|
+
groups.map((group) =>
|
|
220
|
+
runAnimateOnShape(
|
|
221
|
+
group,
|
|
222
|
+
usingFields,
|
|
223
|
+
targetStyle,
|
|
224
|
+
GROUP_ANIMATE_STYLES[isOut ? 1 : 0],
|
|
225
|
+
animateConfig,
|
|
226
|
+
),
|
|
227
|
+
),
|
|
228
|
+
);
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
} else {
|
|
232
|
+
const shape = shapeMap[shapeId];
|
|
233
|
+
if (
|
|
234
|
+
shape &&
|
|
235
|
+
shape.style.display !== 'none' &&
|
|
236
|
+
shape.style.visibility !== 'hidden'
|
|
237
|
+
) {
|
|
238
|
+
const targetStyle =
|
|
239
|
+
targetStylesMap[shapeId] ||
|
|
240
|
+
targetStylesMap.otherShapes?.[shapeId] ||
|
|
241
|
+
{};
|
|
242
|
+
if (hasCanceled) {
|
|
243
|
+
Object.keys(targetStyle).forEach((key) => {
|
|
244
|
+
shape.style[key] = targetStyle[key];
|
|
245
|
+
});
|
|
246
|
+
} else {
|
|
247
|
+
animates.push(
|
|
248
|
+
runAnimateOnShape(
|
|
249
|
+
shape,
|
|
250
|
+
fields,
|
|
251
|
+
targetStyle,
|
|
252
|
+
getShapeAnimateBeginStyles(shape),
|
|
253
|
+
animateConfig,
|
|
254
|
+
),
|
|
255
|
+
);
|
|
256
|
+
}
|
|
236
257
|
}
|
|
237
258
|
}
|
|
238
|
-
|
|
239
|
-
|
|
259
|
+
return animates;
|
|
260
|
+
})
|
|
261
|
+
.flat()
|
|
262
|
+
.filter(Boolean);
|
|
263
|
+
animations.forEach((animation, i) => {
|
|
264
|
+
const { duration } = animation.effect.timing;
|
|
265
|
+
if (maxDuration < duration) {
|
|
240
266
|
maxDuration = duration;
|
|
241
267
|
maxDurationIdx = i;
|
|
242
268
|
}
|
|
@@ -246,7 +272,6 @@ const runAnimateGroupOnShapes = (
|
|
|
246
272
|
cancelAnimations();
|
|
247
273
|
};
|
|
248
274
|
}
|
|
249
|
-
return animation;
|
|
250
275
|
});
|
|
251
276
|
if (maxDurationIdx > -1) {
|
|
252
277
|
const selfOnfinish = animations[maxDurationIdx].onfinish;
|
|
@@ -283,10 +308,10 @@ const runAnimateOnShape = (
|
|
|
283
308
|
fields.forEach((key) => {
|
|
284
309
|
animateArr[0][key] =
|
|
285
310
|
shape.style[key] === undefined
|
|
286
|
-
?
|
|
287
|
-
:
|
|
311
|
+
? cloneJSON(beginStyle[key])
|
|
312
|
+
: cloneJSON(shape.style[key]);
|
|
288
313
|
if (targetStyle[key] === undefined) return;
|
|
289
|
-
animateArr[1][key] =
|
|
314
|
+
animateArr[1][key] = cloneJSON(targetStyle[key]);
|
|
290
315
|
if (key === 'lineDash') {
|
|
291
316
|
const beginPercents = uniq(
|
|
292
317
|
animateArr[0][key].filter(
|
|
@@ -299,7 +324,7 @@ const runAnimateOnShape = (
|
|
|
299
324
|
),
|
|
300
325
|
);
|
|
301
326
|
if (beginPercents.length || targetPercents.length) {
|
|
302
|
-
percentLineDash =
|
|
327
|
+
percentLineDash = cloneJSON(animateArr[0].lineDash);
|
|
303
328
|
const totalLength = (
|
|
304
329
|
shape as Line | Polyline | Path
|
|
305
330
|
).getTotalLength();
|
|
@@ -331,6 +356,8 @@ const runAnimateOnShape = (
|
|
|
331
356
|
);
|
|
332
357
|
return;
|
|
333
358
|
}
|
|
359
|
+
if (animateConfig.iterations === -1 || animateConfig.iterations === null)
|
|
360
|
+
animateConfig.iterations = Infinity;
|
|
334
361
|
const animation = shape.animate(animateArr, animateConfig);
|
|
335
362
|
if (percentLineDash) {
|
|
336
363
|
animation.onfinish = () => {
|
|
@@ -381,7 +408,8 @@ export const animateShapes = (
|
|
|
381
408
|
animates: IAnimates,
|
|
382
409
|
mergedStyles: ItemShapeStyles,
|
|
383
410
|
shapeMap: { [shapeId: string]: DisplayObject },
|
|
384
|
-
|
|
411
|
+
shapeIds: string[] = undefined,
|
|
412
|
+
groups: Group[],
|
|
385
413
|
timing: AnimateTiming = 'buildIn',
|
|
386
414
|
changedStates: string[] = [],
|
|
387
415
|
onAnimatesFrame: Function = () => {},
|
|
@@ -410,7 +438,8 @@ export const animateShapes = (
|
|
|
410
438
|
}
|
|
411
439
|
const groupAnimations = runAnimateGroupOnShapes(
|
|
412
440
|
shapeMap,
|
|
413
|
-
|
|
441
|
+
shapeIds,
|
|
442
|
+
groups,
|
|
414
443
|
timingAnimateGroups[groupKeys[i]],
|
|
415
444
|
mergedStyles,
|
|
416
445
|
timing,
|
package/src/util/bbox.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AABB } from '@antv/g';
|
|
1
|
+
import { AABB, Canvas } from '@antv/g';
|
|
2
2
|
import { Point, PolyPoint } from 'types/common';
|
|
3
3
|
|
|
4
4
|
/**
|
|
@@ -332,3 +332,28 @@ export const isBBoxInBBox = (subBBox: AABB, bbox: AABB, scale?: number) => {
|
|
|
332
332
|
subBBox.max[1] < bbox.max[1]
|
|
333
333
|
);
|
|
334
334
|
};
|
|
335
|
+
|
|
336
|
+
export const getCombinedCanvasesBounds = (canvases: Canvas[]) => {
|
|
337
|
+
const combinedBounds = {
|
|
338
|
+
min: [Infinity, Infinity, Infinity],
|
|
339
|
+
max: [-Infinity, -Infinity, -Infinity],
|
|
340
|
+
center: [0, 0, 0],
|
|
341
|
+
halfExtents: [0, 0, 0],
|
|
342
|
+
};
|
|
343
|
+
canvases.forEach((canvas) => {
|
|
344
|
+
const bounds = canvas.document.documentElement.getBounds();
|
|
345
|
+
combinedBounds.min = combinedBounds.min.map((val, i) =>
|
|
346
|
+
Math.min(val || Infinity, bounds.min[i]),
|
|
347
|
+
);
|
|
348
|
+
combinedBounds.max = combinedBounds.max.map((val, i) =>
|
|
349
|
+
Math.max(val || -Infinity, bounds.max[i]),
|
|
350
|
+
);
|
|
351
|
+
});
|
|
352
|
+
combinedBounds.center = combinedBounds.center.map(
|
|
353
|
+
(_, i) => (combinedBounds.max[i] + combinedBounds.min[i]) / 2,
|
|
354
|
+
);
|
|
355
|
+
combinedBounds.halfExtents = combinedBounds.halfExtents.map(
|
|
356
|
+
(_, i) => (combinedBounds.max[i] - combinedBounds.min[i]) / 2,
|
|
357
|
+
);
|
|
358
|
+
return combinedBounds;
|
|
359
|
+
};
|
package/src/util/data.ts
CHANGED
|
@@ -334,18 +334,27 @@ export const dataLifecycleMap: Record<string, string> = {
|
|
|
334
334
|
* @param excludeInvisibles whether exclude invisibles. true means the function should test without visible items.
|
|
335
335
|
* @returns graph is empty or not.
|
|
336
336
|
*/
|
|
337
|
-
export const isEmptyGraph = (graph, excludeInvisibles = false):
|
|
337
|
+
export const isEmptyGraph = (graph, excludeInvisibles = false): boolean => {
|
|
338
338
|
const nodes = graph.getAllNodesData();
|
|
339
339
|
const combos = graph.getAllCombosData();
|
|
340
340
|
if (nodes.length === 0 && combos.length === 0) return true;
|
|
341
341
|
|
|
342
342
|
if (excludeInvisibles) {
|
|
343
343
|
const edges = graph.getAllEdgesData();
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
if (!hasVisibleItems) return true;
|
|
344
|
+
if (nodes.find((node) => graph.getItemVisible(node.id))) return false;
|
|
345
|
+
if (edges.find((edge) => graph.getItemVisible(edge.id))) return false;
|
|
346
|
+
if (combos.find((combo) => graph.getItemVisible(combo.id))) return false;
|
|
347
|
+
return true;
|
|
349
348
|
}
|
|
350
349
|
return false;
|
|
351
350
|
};
|
|
351
|
+
|
|
352
|
+
/**
|
|
353
|
+
* Clone an object by JSON stringify and parse
|
|
354
|
+
* @param obj
|
|
355
|
+
* @returns
|
|
356
|
+
*/
|
|
357
|
+
export const cloneJSON = (obj) => {
|
|
358
|
+
if (!obj) return obj;
|
|
359
|
+
return JSON.parse(JSON.stringify(obj));
|
|
360
|
+
};
|
package/src/util/dom.ts
CHANGED
|
@@ -4,14 +4,14 @@
|
|
|
4
4
|
* @returns
|
|
5
5
|
*/
|
|
6
6
|
export function createDOM(str: string): HTMLElement {
|
|
7
|
-
const
|
|
8
|
-
|
|
7
|
+
const containerDOM = document.createElement('div');
|
|
8
|
+
containerDOM.innerHTML = str;
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
if (dom &&
|
|
12
|
-
|
|
10
|
+
let dom = containerDOM.childNodes[0] as HTMLElement;
|
|
11
|
+
if (dom && containerDOM.contains(dom)) {
|
|
12
|
+
dom = containerDOM.removeChild(dom);
|
|
13
13
|
}
|
|
14
|
-
return dom
|
|
14
|
+
return dom;
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
/**
|
package/src/util/item.ts
CHANGED
|
@@ -32,6 +32,8 @@ export const upsertTransientItem = (
|
|
|
32
32
|
nodeGroup: Group,
|
|
33
33
|
edgeGroup: Group,
|
|
34
34
|
comboGroup: Group,
|
|
35
|
+
nodeLabelGroup: Group,
|
|
36
|
+
edgeLabelGroup: Group,
|
|
35
37
|
transientItemMap: Map<ID, Node | Edge | Combo | Group>,
|
|
36
38
|
itemMap: Map<ID, Node | Edge | Combo>,
|
|
37
39
|
graphCore?: GraphCore,
|
|
@@ -56,7 +58,7 @@ export const upsertTransientItem = (
|
|
|
56
58
|
visible = true,
|
|
57
59
|
} = drawOptions;
|
|
58
60
|
if (item.type === 'node') {
|
|
59
|
-
transientItem = item.clone(nodeGroup, shapeIds, true);
|
|
61
|
+
transientItem = item.clone(nodeGroup, nodeLabelGroup, shapeIds, true);
|
|
60
62
|
} else if (item.type === 'edge') {
|
|
61
63
|
let source;
|
|
62
64
|
let target;
|
|
@@ -66,6 +68,8 @@ export const upsertTransientItem = (
|
|
|
66
68
|
nodeGroup,
|
|
67
69
|
edgeGroup,
|
|
68
70
|
comboGroup,
|
|
71
|
+
nodeLabelGroup,
|
|
72
|
+
edgeLabelGroup,
|
|
69
73
|
transientItemMap,
|
|
70
74
|
itemMap,
|
|
71
75
|
graphCore,
|
|
@@ -79,6 +83,8 @@ export const upsertTransientItem = (
|
|
|
79
83
|
nodeGroup,
|
|
80
84
|
edgeGroup,
|
|
81
85
|
comboGroup,
|
|
86
|
+
nodeLabelGroup,
|
|
87
|
+
edgeLabelGroup,
|
|
82
88
|
transientItemMap,
|
|
83
89
|
itemMap,
|
|
84
90
|
graphCore,
|
|
@@ -88,10 +94,13 @@ export const upsertTransientItem = (
|
|
|
88
94
|
}
|
|
89
95
|
transientItem = item.clone(
|
|
90
96
|
edgeGroup,
|
|
97
|
+
edgeLabelGroup,
|
|
91
98
|
source,
|
|
92
99
|
target,
|
|
93
100
|
shapeIds,
|
|
94
101
|
true,
|
|
102
|
+
visible,
|
|
103
|
+
transientItemMap,
|
|
95
104
|
) as Edge;
|
|
96
105
|
} else {
|
|
97
106
|
// find the succeeds to upsert transients
|
|
@@ -106,6 +115,8 @@ export const upsertTransientItem = (
|
|
|
106
115
|
nodeGroup,
|
|
107
116
|
edgeGroup,
|
|
108
117
|
comboGroup,
|
|
118
|
+
nodeLabelGroup,
|
|
119
|
+
edgeLabelGroup,
|
|
109
120
|
transientItemMap,
|
|
110
121
|
itemMap,
|
|
111
122
|
graphCore,
|
|
@@ -117,6 +128,7 @@ export const upsertTransientItem = (
|
|
|
117
128
|
});
|
|
118
129
|
transientItem = (item as Combo).clone(
|
|
119
130
|
comboGroup,
|
|
131
|
+
nodeLabelGroup,
|
|
120
132
|
shapeIds,
|
|
121
133
|
true,
|
|
122
134
|
() => getCombinedBoundsByItem(childItems), // getCombinedBounds
|
|
@@ -143,6 +155,8 @@ export const upsertTransientItem = (
|
|
|
143
155
|
nodeGroup,
|
|
144
156
|
edgeGroup,
|
|
145
157
|
comboGroup,
|
|
158
|
+
nodeLabelGroup,
|
|
159
|
+
edgeLabelGroup,
|
|
146
160
|
transientItemMap,
|
|
147
161
|
itemMap,
|
|
148
162
|
graphCore,
|
package/src/util/mapper.ts
CHANGED
|
@@ -32,7 +32,7 @@ export const DEFAULT_MAPPER = {
|
|
|
32
32
|
},
|
|
33
33
|
edge: (innerEdgeModel) => {
|
|
34
34
|
const { id, source, target, data } = innerEdgeModel;
|
|
35
|
-
const { color, label, icon, badge, keyShape } = data;
|
|
35
|
+
const { color, label, icon, badge, keyShape } = data || {};
|
|
36
36
|
const resultData: NodeDisplayModelData = {
|
|
37
37
|
...data,
|
|
38
38
|
keyShape: { ...keyShape },
|
package/src/util/path.ts
CHANGED
|
@@ -35,9 +35,79 @@ export const getControlPoint = (
|
|
|
35
35
|
return point;
|
|
36
36
|
};
|
|
37
37
|
|
|
38
|
-
|
|
38
|
+
const PATH_COMMANDS = {
|
|
39
|
+
M: ['x', 'y'],
|
|
40
|
+
m: ['dx', 'dy'],
|
|
41
|
+
H: ['x'],
|
|
42
|
+
h: ['dx'],
|
|
43
|
+
V: ['y'],
|
|
44
|
+
v: ['dy'],
|
|
45
|
+
L: ['x', 'y'],
|
|
46
|
+
l: ['dx', 'dy'],
|
|
47
|
+
Z: [],
|
|
48
|
+
C: ['x1', 'y1', 'x2', 'y2', 'x', 'y'],
|
|
49
|
+
c: ['dx1', 'dy1', 'dx2', 'dy2', 'dx', 'dy'],
|
|
50
|
+
S: ['x2', 'y2', 'x', 'y'],
|
|
51
|
+
s: ['dx2', 'dy2', 'dx', 'dy'],
|
|
52
|
+
Q: ['x1', 'y1', 'x', 'y'],
|
|
53
|
+
q: ['dx1', 'dy1', 'dx', 'dy'],
|
|
54
|
+
T: ['x', 'y'],
|
|
55
|
+
t: ['dx', 'dy'],
|
|
56
|
+
A: ['rx', 'ry', 'rotation', 'large-arc', 'sweep', 'x', 'y'],
|
|
57
|
+
a: ['rx', 'ry', 'rotation', 'large-arc', 'sweep', 'dx', 'dy'],
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Converts a path string to an array of path segments.
|
|
62
|
+
* @param {string} path - The path string to convert.
|
|
63
|
+
* @returns {Array} - An array of path segments.
|
|
64
|
+
**/
|
|
65
|
+
const fromPathToArray = (path: string) => {
|
|
66
|
+
const items = path
|
|
67
|
+
.replace(/[\n\r]/g, '')
|
|
68
|
+
.replace(/-/g, ' -')
|
|
69
|
+
.replace(/(\d*\.)(\d+)(?=\.)/g, '$1$2 ')
|
|
70
|
+
.trim()
|
|
71
|
+
.split(/\s*,|\s+/);
|
|
72
|
+
const segments = [];
|
|
73
|
+
let currentCommand = '';
|
|
74
|
+
let currentElement = {};
|
|
75
|
+
while (items.length > 0) {
|
|
76
|
+
let it = items.shift();
|
|
77
|
+
if (PATH_COMMANDS.hasOwnProperty(it)) {
|
|
78
|
+
currentCommand = it;
|
|
79
|
+
} else {
|
|
80
|
+
items.unshift(it);
|
|
81
|
+
}
|
|
82
|
+
currentElement = { type: currentCommand };
|
|
83
|
+
PATH_COMMANDS[currentCommand].forEach((prop) => {
|
|
84
|
+
it = items.shift(); // TODO sanity check
|
|
85
|
+
currentElement[prop] = it;
|
|
86
|
+
});
|
|
87
|
+
if (currentCommand === 'M') {
|
|
88
|
+
currentCommand = 'L';
|
|
89
|
+
} else if (currentCommand === 'm') {
|
|
90
|
+
currentCommand = 'l';
|
|
91
|
+
}
|
|
92
|
+
segments.push(currentElement);
|
|
93
|
+
}
|
|
94
|
+
return segments;
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Converts a path to an array of points.
|
|
99
|
+
* @param {Array|string} path - The path to convert to points.
|
|
100
|
+
* @returns {Array} - An array of points.
|
|
101
|
+
*/
|
|
102
|
+
export const pathToPoints = (path: any[] | string) => {
|
|
39
103
|
const points = [];
|
|
40
|
-
|
|
104
|
+
let segments = [];
|
|
105
|
+
if (typeof path === 'string') {
|
|
106
|
+
segments = fromPathToArray(path);
|
|
107
|
+
} else {
|
|
108
|
+
segments = path;
|
|
109
|
+
}
|
|
110
|
+
segments.forEach((seg) => {
|
|
41
111
|
const command = seg[0];
|
|
42
112
|
if (command !== 'A') {
|
|
43
113
|
for (let i = 1; i < seg.length; i = i + 2) {
|
package/src/util/polyline.ts
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import { AABB } from '@antv/g';
|
|
2
2
|
import { each } from '@antv/util';
|
|
3
3
|
import { ID } from '@antv/graphlib';
|
|
4
|
+
import { EdgeDisplayModel } from '../types/edge';
|
|
5
|
+
import { NodeDisplayModel } from '../types';
|
|
4
6
|
import Node from '../item/node';
|
|
7
|
+
import Item from '../item/item';
|
|
5
8
|
import { Point, PolyPoint } from '../types/common';
|
|
6
9
|
import {
|
|
7
10
|
getBBoxFromPoint,
|
|
@@ -18,24 +21,6 @@ import { manhattanDist } from './math';
|
|
|
18
21
|
import { RouterCfg } from './router';
|
|
19
22
|
import { isBending } from './point';
|
|
20
23
|
|
|
21
|
-
// class PolylineHistory {
|
|
22
|
-
// private pathMap: Map<ID, Point[]>;
|
|
23
|
-
|
|
24
|
-
// constructor() {
|
|
25
|
-
// this.pathMap = new Map<ID, Point[]>();
|
|
26
|
-
// }
|
|
27
|
-
|
|
28
|
-
// public addPath(edgeId: ID, points: Point[]): void {
|
|
29
|
-
// this.pathMap.set(edgeId, points);
|
|
30
|
-
// }
|
|
31
|
-
|
|
32
|
-
// public getPointsById(edgeId: ID): Point[] | undefined {
|
|
33
|
-
// return this.pathMap.get(edgeId);
|
|
34
|
-
// }
|
|
35
|
-
// }
|
|
36
|
-
|
|
37
|
-
// const polylineHistory = new PolylineHistory();
|
|
38
|
-
|
|
39
24
|
/**
|
|
40
25
|
* Simplify points of polyline by removing duplicated points
|
|
41
26
|
* @param points list of 2d points
|
|
@@ -341,9 +326,6 @@ export const getPolylinePath = (
|
|
|
341
326
|
|
|
342
327
|
const newPoints = removeRedundantPoint(points);
|
|
343
328
|
|
|
344
|
-
// Record polyline points
|
|
345
|
-
// polylineHistory.addPath(id, newPoints);
|
|
346
|
-
|
|
347
329
|
return pointsToPolyline(newPoints, radius, z);
|
|
348
330
|
};
|
|
349
331
|
|
|
@@ -436,8 +418,6 @@ export const getPolylinePoints = (
|
|
|
436
418
|
start,
|
|
437
419
|
end,
|
|
438
420
|
);
|
|
439
|
-
pathPoints.unshift(start);
|
|
440
|
-
pathPoints.push(end);
|
|
441
421
|
|
|
442
422
|
return simplifyPolylinePoints(pathPoints);
|
|
443
423
|
};
|
|
@@ -675,3 +655,30 @@ export class EdgeCollisionChecker {
|
|
|
675
655
|
return potentialCollisions;
|
|
676
656
|
}
|
|
677
657
|
}
|
|
658
|
+
|
|
659
|
+
/**
|
|
660
|
+
* Check if the edge is a polyline and obstacle avoidance is enabled
|
|
661
|
+
*/
|
|
662
|
+
export const isPolylineWithObstacleAvoidance = (
|
|
663
|
+
displayModel: EdgeDisplayModel,
|
|
664
|
+
polylineEdgeType = ['polyline-edge'],
|
|
665
|
+
) => {
|
|
666
|
+
const { type, keyShape } = displayModel.data;
|
|
667
|
+
const isPolyline = polylineEdgeType.includes(type);
|
|
668
|
+
if (!isPolyline) return false;
|
|
669
|
+
// @ts-ignore
|
|
670
|
+
const isObstacleAvoidanceEnabled = (keyShape?.routeCfg as RouterCfg)
|
|
671
|
+
?.enableObstacleAvoidance;
|
|
672
|
+
return isObstacleAvoidanceEnabled;
|
|
673
|
+
};
|
|
674
|
+
|
|
675
|
+
/**
|
|
676
|
+
* Check if the node prevents polyline edges from overlapping
|
|
677
|
+
*/
|
|
678
|
+
export const isPointPreventPolylineOverlap = (
|
|
679
|
+
displayModel: NodeDisplayModel,
|
|
680
|
+
) => {
|
|
681
|
+
if (!displayModel) return false;
|
|
682
|
+
const { preventPolylineEdgeOverlap } = displayModel.data;
|
|
683
|
+
return preventPolylineEdgeOverlap || false;
|
|
684
|
+
};
|