@antv/g6 5.0.0-beta.5 → 5.0.0-beta.6
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/index.d.ts +13 -1
- package/esm/index.js +1 -1
- package/esm/item/combo.d.ts +1 -1
- package/esm/item/combo.js +16 -9
- package/esm/item/combo.js.map +1 -1
- package/esm/item/edge.d.ts +1 -1
- package/esm/item/edge.js +15 -7
- package/esm/item/edge.js.map +1 -1
- package/esm/item/node.d.ts +1 -1
- package/esm/item/node.js +16 -9
- package/esm/item/node.js.map +1 -1
- package/esm/runtime/controller/item.d.ts +1 -0
- package/esm/runtime/controller/item.js +19 -3
- package/esm/runtime/controller/item.js.map +1 -1
- package/esm/runtime/graph.d.ts +82 -4
- package/esm/runtime/graph.js +361 -47
- package/esm/runtime/graph.js.map +1 -1
- package/esm/stdlib/behavior/brush-select.js +1 -2
- package/esm/stdlib/behavior/brush-select.js.map +1 -1
- package/esm/stdlib/behavior/create-edge.d.ts +57 -0
- package/esm/stdlib/behavior/create-edge.js +206 -0
- package/esm/stdlib/behavior/create-edge.js.map +1 -0
- package/esm/stdlib/behavior/drag-canvas.d.ts +1 -1
- package/esm/stdlib/behavior/drag-canvas.js +7 -7
- package/esm/stdlib/behavior/drag-canvas.js.map +1 -1
- package/esm/stdlib/behavior/drag-combo.d.ts +2 -2
- package/esm/stdlib/behavior/drag-combo.js +35 -24
- package/esm/stdlib/behavior/drag-combo.js.map +1 -1
- package/esm/stdlib/behavior/drag-node.d.ts +3 -3
- package/esm/stdlib/behavior/drag-node.js +70 -57
- package/esm/stdlib/behavior/drag-node.js.map +1 -1
- package/esm/stdlib/behavior/index.d.ts +2 -0
- package/esm/stdlib/behavior/index.js +2 -0
- package/esm/stdlib/behavior/index.js.map +1 -1
- package/esm/stdlib/behavior/lasso-select.d.ts +1 -1
- package/esm/stdlib/behavior/lasso-select.js +1 -2
- package/esm/stdlib/behavior/lasso-select.js.map +1 -1
- package/esm/stdlib/behavior/scroll-canvas.d.ts +67 -0
- package/esm/stdlib/behavior/scroll-canvas.js +266 -0
- package/esm/stdlib/behavior/scroll-canvas.js.map +1 -0
- package/esm/stdlib/behavior/zoom-canvas.d.ts +1 -1
- package/esm/stdlib/behavior/zoom-canvas.js +7 -7
- package/esm/stdlib/behavior/zoom-canvas.js.map +1 -1
- package/esm/stdlib/index.d.ts +4 -0
- package/esm/stdlib/index.js +5 -1
- package/esm/stdlib/index.js.map +1 -1
- package/esm/stdlib/plugin/hull/hullComponent.d.ts +1 -1
- package/esm/stdlib/plugin/hull/hullComponent.js +3 -6
- package/esm/stdlib/plugin/hull/hullComponent.js.map +1 -1
- package/esm/stdlib/plugin/minimap/index.d.ts +5 -1
- package/esm/stdlib/plugin/minimap/index.js +109 -8
- package/esm/stdlib/plugin/minimap/index.js.map +1 -1
- package/esm/types/graph.d.ts +31 -5
- package/esm/types/hook.d.ts +16 -2
- package/esm/types/spec.d.ts +6 -3
- package/esm/util/item.d.ts +16 -1
- package/esm/util/item.js +31 -8
- package/esm/util/item.js.map +1 -1
- package/esm/util/warn.d.ts +14 -0
- package/esm/util/warn.js +4 -0
- package/esm/util/warn.js.map +1 -0
- package/lib/index.d.ts +13 -1
- package/lib/index.js +1 -1
- package/lib/item/combo.d.ts +1 -1
- package/lib/item/combo.js +16 -9
- package/lib/item/combo.js.map +1 -1
- package/lib/item/edge.d.ts +1 -1
- package/lib/item/edge.js +15 -7
- package/lib/item/edge.js.map +1 -1
- package/lib/item/node.d.ts +1 -1
- package/lib/item/node.js +16 -9
- package/lib/item/node.js.map +1 -1
- package/lib/runtime/controller/item.d.ts +1 -0
- package/lib/runtime/controller/item.js +19 -3
- package/lib/runtime/controller/item.js.map +1 -1
- package/lib/runtime/graph.d.ts +82 -4
- package/lib/runtime/graph.js +361 -47
- package/lib/runtime/graph.js.map +1 -1
- package/lib/stdlib/behavior/brush-select.js +1 -2
- package/lib/stdlib/behavior/brush-select.js.map +1 -1
- package/lib/stdlib/behavior/create-edge.d.ts +57 -0
- package/lib/stdlib/behavior/create-edge.js +210 -0
- package/lib/stdlib/behavior/create-edge.js.map +1 -0
- package/lib/stdlib/behavior/drag-canvas.d.ts +1 -1
- package/lib/stdlib/behavior/drag-canvas.js +7 -7
- package/lib/stdlib/behavior/drag-canvas.js.map +1 -1
- package/lib/stdlib/behavior/drag-combo.d.ts +2 -2
- package/lib/stdlib/behavior/drag-combo.js +35 -24
- package/lib/stdlib/behavior/drag-combo.js.map +1 -1
- package/lib/stdlib/behavior/drag-node.d.ts +3 -3
- package/lib/stdlib/behavior/drag-node.js +70 -57
- package/lib/stdlib/behavior/drag-node.js.map +1 -1
- package/lib/stdlib/behavior/index.d.ts +2 -0
- package/lib/stdlib/behavior/index.js +2 -0
- package/lib/stdlib/behavior/index.js.map +1 -1
- package/lib/stdlib/behavior/lasso-select.d.ts +1 -1
- package/lib/stdlib/behavior/lasso-select.js +1 -2
- package/lib/stdlib/behavior/lasso-select.js.map +1 -1
- package/lib/stdlib/behavior/scroll-canvas.d.ts +67 -0
- package/lib/stdlib/behavior/scroll-canvas.js +270 -0
- package/lib/stdlib/behavior/scroll-canvas.js.map +1 -0
- package/lib/stdlib/behavior/zoom-canvas.d.ts +1 -1
- package/lib/stdlib/behavior/zoom-canvas.js +7 -7
- package/lib/stdlib/behavior/zoom-canvas.js.map +1 -1
- package/lib/stdlib/index.d.ts +4 -0
- package/lib/stdlib/index.js +5 -1
- package/lib/stdlib/index.js.map +1 -1
- package/lib/stdlib/plugin/hull/hullComponent.d.ts +1 -1
- package/lib/stdlib/plugin/hull/hullComponent.js +3 -6
- package/lib/stdlib/plugin/hull/hullComponent.js.map +1 -1
- package/lib/stdlib/plugin/minimap/index.d.ts +5 -1
- package/lib/stdlib/plugin/minimap/index.js +109 -8
- package/lib/stdlib/plugin/minimap/index.js.map +1 -1
- package/lib/types/graph.d.ts +31 -5
- package/lib/types/hook.d.ts +16 -2
- package/lib/types/spec.d.ts +6 -3
- package/lib/util/item.d.ts +16 -1
- package/lib/util/item.js +33 -9
- package/lib/util/item.js.map +1 -1
- package/lib/util/warn.d.ts +14 -0
- package/lib/util/warn.js +8 -0
- package/lib/util/warn.js.map +1 -0
- package/package.json +1 -1
- package/src/index.ts +1 -1
- package/src/item/combo.ts +14 -9
- package/src/item/edge.ts +13 -7
- package/src/item/node.ts +14 -9
- package/src/runtime/controller/item.ts +28 -6
- package/src/runtime/graph.ts +445 -51
- package/src/stdlib/behavior/brush-select.ts +4 -2
- package/src/stdlib/behavior/create-edge.ts +295 -0
- package/src/stdlib/behavior/drag-canvas.ts +8 -8
- package/src/stdlib/behavior/drag-combo.ts +2 -2
- package/src/stdlib/behavior/drag-node.ts +8 -8
- package/src/stdlib/behavior/index.ts +2 -0
- package/src/stdlib/behavior/lasso-select.ts +5 -3
- package/src/stdlib/behavior/scroll-canvas.ts +348 -0
- package/src/stdlib/behavior/zoom-canvas.ts +8 -8
- package/src/stdlib/index.ts +6 -0
- package/src/stdlib/plugin/hull/hullComponent.ts +8 -5
- package/src/stdlib/plugin/minimap/index.ts +113 -9
- package/src/types/graph.ts +31 -5
- package/src/types/hook.ts +16 -2
- package/src/types/spec.ts +9 -3
- package/src/util/item.ts +65 -28
- package/src/util/warn.ts +20 -0
|
@@ -0,0 +1,295 @@
|
|
|
1
|
+
import type { IG6GraphEvent } from '../../types';
|
|
2
|
+
import { warn } from '../../util/warn';
|
|
3
|
+
import { generateEdgeID } from '../../util/item';
|
|
4
|
+
import { Behavior } from '../../types/behavior';
|
|
5
|
+
import { EdgeDisplayModelData } from '../../types/edge';
|
|
6
|
+
|
|
7
|
+
const KEYBOARD_TRIGGERS = ['shift', 'ctrl', 'control', 'alt', 'meta'] as const;
|
|
8
|
+
const EVENT_TRIGGERS = ['click', 'drag'] as const;
|
|
9
|
+
|
|
10
|
+
const VIRTUAL_EDGE_ID = 'g6-create-edge-virtual-edge';
|
|
11
|
+
const DUMMY_NODE_ID = 'g6-create-edge-dummy-node';
|
|
12
|
+
|
|
13
|
+
// type Trigger = (typeof EVENT_TRIGGERS)[number];
|
|
14
|
+
|
|
15
|
+
interface CreateEdgeOptions {
|
|
16
|
+
/**
|
|
17
|
+
* The triggering conditions for this interaction can be either 'click' or 'drag'.
|
|
18
|
+
* Default to `click`.
|
|
19
|
+
*/
|
|
20
|
+
trigger: (typeof EVENT_TRIGGERS)[number];
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Keyboard keys serve as auxiliary triggers for this interaction.
|
|
24
|
+
* cound be 'shift', 'ctrl', 'control', 'alt', 'meta', undefined.
|
|
25
|
+
*/
|
|
26
|
+
key?: (typeof KEYBOARD_TRIGGERS)[number];
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Config of the created edge.
|
|
30
|
+
*/
|
|
31
|
+
edgeConfig: EdgeDisplayModelData;
|
|
32
|
+
/**
|
|
33
|
+
* The event name to trigger after creating the virtual edge.
|
|
34
|
+
*/
|
|
35
|
+
createVirtualEventName?: string;
|
|
36
|
+
/**
|
|
37
|
+
* The event name to trigger after creating the actual edge.
|
|
38
|
+
*/
|
|
39
|
+
createActualEventName?: string;
|
|
40
|
+
/**
|
|
41
|
+
* The event name to trigger after canceling the behavior.
|
|
42
|
+
*/
|
|
43
|
+
cancelCreateEventName?: string;
|
|
44
|
+
/**
|
|
45
|
+
* Whether allow the behavior happen on the current item.
|
|
46
|
+
*/
|
|
47
|
+
shouldBegin: (event: IG6GraphEvent) => boolean;
|
|
48
|
+
/**
|
|
49
|
+
*
|
|
50
|
+
* Whether it is allowed to end the creation of edges under the current conditions being operated.
|
|
51
|
+
*/
|
|
52
|
+
shouldEnd: (event: IG6GraphEvent) => boolean;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
const DEFAULT_OPTIONS: CreateEdgeOptions = {
|
|
56
|
+
trigger: 'click',
|
|
57
|
+
key: undefined,
|
|
58
|
+
shouldBegin: () => true,
|
|
59
|
+
shouldEnd: () => false,
|
|
60
|
+
edgeConfig: {},
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
export class CreateEdge extends Behavior {
|
|
64
|
+
isKeyDown = false;
|
|
65
|
+
addingEdge = null;
|
|
66
|
+
dummyNode = null;
|
|
67
|
+
|
|
68
|
+
constructor(options: Partial<CreateEdgeOptions>) {
|
|
69
|
+
super(Object.assign({}, DEFAULT_OPTIONS, options));
|
|
70
|
+
this.validateOptions(options);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
validateOptions(options: Partial<CreateEdgeOptions>) {
|
|
74
|
+
if (options.trigger && !EVENT_TRIGGERS.includes(options.trigger)) {
|
|
75
|
+
warn({
|
|
76
|
+
optionName: `create-edge.trigger`,
|
|
77
|
+
shouldBe: EVENT_TRIGGERS,
|
|
78
|
+
now: options.trigger,
|
|
79
|
+
scope: 'behavior',
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
this.options.trigger = DEFAULT_OPTIONS.trigger;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
if (options.key && !KEYBOARD_TRIGGERS.includes(options.key)) {
|
|
86
|
+
warn({
|
|
87
|
+
optionName: `create-edge.key`,
|
|
88
|
+
shouldBe: KEYBOARD_TRIGGERS,
|
|
89
|
+
now: options.key,
|
|
90
|
+
scope: 'behavior',
|
|
91
|
+
});
|
|
92
|
+
this.options.key = DEFAULT_OPTIONS.key;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
getEvents = () => {
|
|
97
|
+
const { trigger, key } = this.options;
|
|
98
|
+
const [CLICK_NAME] = EVENT_TRIGGERS;
|
|
99
|
+
|
|
100
|
+
const triggerEvents =
|
|
101
|
+
trigger === CLICK_NAME
|
|
102
|
+
? {
|
|
103
|
+
'node:click': this.handleCreateEdge,
|
|
104
|
+
pointermove: this.updateEndPoint,
|
|
105
|
+
'edge:click': this.cancelCreating,
|
|
106
|
+
'canvas:click': this.cancelCreating,
|
|
107
|
+
'combo:click': this.handleCreateEdge,
|
|
108
|
+
}
|
|
109
|
+
: {
|
|
110
|
+
'node:dragstart': this.handleCreateEdge,
|
|
111
|
+
'combo:dragstart': this.handleCreateEdge,
|
|
112
|
+
drag: this.updateEndPoint,
|
|
113
|
+
drop: this.onDrop,
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
const keyboardEvents = key
|
|
117
|
+
? {
|
|
118
|
+
keydown: this.onKeyDown,
|
|
119
|
+
keyup: this.onKeyUp,
|
|
120
|
+
}
|
|
121
|
+
: {};
|
|
122
|
+
|
|
123
|
+
return { ...triggerEvents, ...keyboardEvents } as Record<
|
|
124
|
+
string,
|
|
125
|
+
(e: IG6GraphEvent) => void
|
|
126
|
+
>;
|
|
127
|
+
};
|
|
128
|
+
|
|
129
|
+
handleCreateEdge = (e: IG6GraphEvent) => {
|
|
130
|
+
if (this.options.key && !this.isKeyDown) {
|
|
131
|
+
return;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
if (this.options.shouldEnd(e)) {
|
|
135
|
+
return;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
const { graph, options, addingEdge } = this;
|
|
139
|
+
const currentNodeId = e.itemId;
|
|
140
|
+
|
|
141
|
+
const { edgeConfig, createVirtualEventName, createActualEventName } =
|
|
142
|
+
options;
|
|
143
|
+
|
|
144
|
+
if (addingEdge) {
|
|
145
|
+
// create edge end, add the actual edge to graph and remove the virtual edge and node
|
|
146
|
+
graph.addData('edge', {
|
|
147
|
+
id: generateEdgeID(addingEdge.source, currentNodeId),
|
|
148
|
+
source: addingEdge.source,
|
|
149
|
+
target: currentNodeId,
|
|
150
|
+
data: {
|
|
151
|
+
...edgeConfig,
|
|
152
|
+
type:
|
|
153
|
+
currentNodeId === addingEdge.source ? 'loop-edge' : edgeConfig.type,
|
|
154
|
+
},
|
|
155
|
+
});
|
|
156
|
+
if (createActualEventName) {
|
|
157
|
+
graph.emit(createActualEventName, { edge: addingEdge });
|
|
158
|
+
}
|
|
159
|
+
this.cancelCreating();
|
|
160
|
+
|
|
161
|
+
return;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
this.dummyNode = graph.addData('node', {
|
|
165
|
+
id: DUMMY_NODE_ID,
|
|
166
|
+
data: {
|
|
167
|
+
x: e.canvas.x,
|
|
168
|
+
y: e.canvas.y,
|
|
169
|
+
keyShape: {
|
|
170
|
+
opacity: 0,
|
|
171
|
+
interactive: false,
|
|
172
|
+
},
|
|
173
|
+
labelShape: {
|
|
174
|
+
opacity: 0,
|
|
175
|
+
},
|
|
176
|
+
anchorPoints: [[0.5, 0.5]],
|
|
177
|
+
},
|
|
178
|
+
});
|
|
179
|
+
this.addingEdge = graph.addData('edge', {
|
|
180
|
+
id: VIRTUAL_EDGE_ID,
|
|
181
|
+
source: currentNodeId,
|
|
182
|
+
target: DUMMY_NODE_ID,
|
|
183
|
+
data: {
|
|
184
|
+
...edgeConfig,
|
|
185
|
+
},
|
|
186
|
+
});
|
|
187
|
+
if (createVirtualEventName) {
|
|
188
|
+
graph.emit(createVirtualEventName, { edge: this.addingEdge });
|
|
189
|
+
}
|
|
190
|
+
};
|
|
191
|
+
|
|
192
|
+
onDrop = async (e: IG6GraphEvent) => {
|
|
193
|
+
const { addingEdge, options, graph } = this;
|
|
194
|
+
|
|
195
|
+
const { edgeConfig, key, createActualEventName } = options;
|
|
196
|
+
if (key && !this.isKeyDown) {
|
|
197
|
+
return;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
if (!addingEdge) {
|
|
201
|
+
return;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
const elements = await this.graph.canvas.document.elementsFromPoint(
|
|
205
|
+
e.canvas.x,
|
|
206
|
+
e.canvas.y,
|
|
207
|
+
);
|
|
208
|
+
const currentIds = elements
|
|
209
|
+
// @ts-ignore TODO: G type
|
|
210
|
+
.map((ele) => ele.parentNode.getAttribute?.('data-item-id'))
|
|
211
|
+
.filter((id) => id !== undefined && !DUMMY_NODE_ID !== id);
|
|
212
|
+
const dropId = currentIds.find(
|
|
213
|
+
(id) => this.graph.getComboData(id) || this.graph.getNodeData(id),
|
|
214
|
+
);
|
|
215
|
+
|
|
216
|
+
if (!dropId) {
|
|
217
|
+
this.cancelCreating();
|
|
218
|
+
return;
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
graph.addData('edge', {
|
|
222
|
+
id: generateEdgeID(addingEdge.source, dropId),
|
|
223
|
+
source: addingEdge.source,
|
|
224
|
+
target: dropId,
|
|
225
|
+
data: {
|
|
226
|
+
...edgeConfig,
|
|
227
|
+
type: dropId === addingEdge.source ? 'loop-edge' : edgeConfig.type,
|
|
228
|
+
},
|
|
229
|
+
});
|
|
230
|
+
if (createActualEventName) {
|
|
231
|
+
graph.emit(createActualEventName, { edge: addingEdge });
|
|
232
|
+
}
|
|
233
|
+
this.cancelCreating();
|
|
234
|
+
};
|
|
235
|
+
|
|
236
|
+
updateEndPoint = (e: IG6GraphEvent) => {
|
|
237
|
+
const { options, graph, addingEdge, isKeyDown } = this;
|
|
238
|
+
if (options.key && !isKeyDown) {
|
|
239
|
+
return;
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
if (!addingEdge) {
|
|
243
|
+
return;
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
const sourceId = addingEdge.source,
|
|
247
|
+
targetId = addingEdge.target;
|
|
248
|
+
|
|
249
|
+
if (!graph.getItemById(sourceId)) {
|
|
250
|
+
this.addingEdge = null;
|
|
251
|
+
return;
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
graph.updatePosition('node', {
|
|
255
|
+
id: targetId,
|
|
256
|
+
data: {
|
|
257
|
+
x: e.canvas.x,
|
|
258
|
+
y: e.canvas.y,
|
|
259
|
+
},
|
|
260
|
+
});
|
|
261
|
+
};
|
|
262
|
+
|
|
263
|
+
cancelCreating = () => {
|
|
264
|
+
if (this.addingEdge) {
|
|
265
|
+
this.graph.removeData('edge', VIRTUAL_EDGE_ID);
|
|
266
|
+
this.addingEdge = null;
|
|
267
|
+
}
|
|
268
|
+
if (this.dummyNode) {
|
|
269
|
+
this.graph.removeData('node', DUMMY_NODE_ID);
|
|
270
|
+
this.dummyNode = null;
|
|
271
|
+
}
|
|
272
|
+
if (this.options.cancelCreateEventName) {
|
|
273
|
+
this.graph.emit(this.options.cancelCreateEventName, {});
|
|
274
|
+
}
|
|
275
|
+
};
|
|
276
|
+
|
|
277
|
+
onKeyDown = (e: KeyboardEvent) => {
|
|
278
|
+
const code = e.key;
|
|
279
|
+
|
|
280
|
+
if (!code) {
|
|
281
|
+
return;
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
if (code.toLocaleLowerCase() === this.options.key) {
|
|
285
|
+
this.isKeyDown = true;
|
|
286
|
+
}
|
|
287
|
+
};
|
|
288
|
+
|
|
289
|
+
onKeyUp = (e: IG6GraphEvent) => {
|
|
290
|
+
if (this.addingEdge) {
|
|
291
|
+
this.cancelCreating();
|
|
292
|
+
}
|
|
293
|
+
this.isKeyDown = false;
|
|
294
|
+
};
|
|
295
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { isNumber } from '@antv/util';
|
|
2
|
+
import { ID, IG6GraphEvent } from '../../types';
|
|
2
3
|
import { Behavior } from '../../types/behavior';
|
|
3
4
|
import { Point } from '../../types/common';
|
|
4
|
-
import { isNumber } from '@antv/util';
|
|
5
5
|
|
|
6
6
|
const VALID_TRIGGERS = ['drag', 'directionKeys'];
|
|
7
7
|
export interface DragCanvasOptions {
|
|
@@ -165,12 +165,12 @@ export class DragCanvas extends Behavior {
|
|
|
165
165
|
return;
|
|
166
166
|
}
|
|
167
167
|
const section = sections.shift();
|
|
168
|
-
graph.
|
|
168
|
+
graph.executeWithNoStack(() => {
|
|
169
|
+
graph.hideItem(section, false, true);
|
|
170
|
+
});
|
|
169
171
|
requestId = requestAnimationFrame(update);
|
|
170
172
|
};
|
|
171
|
-
|
|
172
|
-
requestId = requestAnimationFrame(update);
|
|
173
|
-
});
|
|
173
|
+
requestId = requestAnimationFrame(update);
|
|
174
174
|
}
|
|
175
175
|
}
|
|
176
176
|
|
|
@@ -285,12 +285,12 @@ export class DragCanvas extends Behavior {
|
|
|
285
285
|
cancelAnimationFrame(requestId);
|
|
286
286
|
return;
|
|
287
287
|
}
|
|
288
|
+
graph.startHistoryBatch();
|
|
288
289
|
graph.showItem(sections.shift(), false);
|
|
290
|
+
graph.stopHistoryBatch();
|
|
289
291
|
requestId = requestAnimationFrame(update);
|
|
290
292
|
};
|
|
291
|
-
graph.startHistoryBatch();
|
|
292
293
|
requestId = requestAnimationFrame(update);
|
|
293
|
-
graph.stopHistoryBatch();
|
|
294
294
|
}
|
|
295
295
|
}
|
|
296
296
|
}
|
|
@@ -526,8 +526,8 @@ export class DragCombo extends Behavior {
|
|
|
526
526
|
this.originPositions = [];
|
|
527
527
|
}
|
|
528
528
|
|
|
529
|
-
public onDropNode(event: IG6GraphEvent) {
|
|
530
|
-
const elements = this.graph.canvas.document.
|
|
529
|
+
public async onDropNode(event: IG6GraphEvent) {
|
|
530
|
+
const elements = await this.graph.canvas.document.elementsFromPoint(
|
|
531
531
|
event.canvas.x,
|
|
532
532
|
event.canvas.y,
|
|
533
533
|
);
|
|
@@ -457,7 +457,7 @@ export class DragNode extends Behavior {
|
|
|
457
457
|
this.graph.drawTransient('rect', DELEGATE_SHAPE_ID, { action: 'remove' });
|
|
458
458
|
}
|
|
459
459
|
|
|
460
|
-
public clearTransientItems() {
|
|
460
|
+
public clearTransientItems(positions: Array<Position>) {
|
|
461
461
|
this.hiddenEdges.forEach((edge) => {
|
|
462
462
|
this.graph.drawTransient('node', edge.source, { action: 'remove' });
|
|
463
463
|
this.graph.drawTransient('node', edge.target, { action: 'remove' });
|
|
@@ -472,7 +472,7 @@ export class DragNode extends Behavior {
|
|
|
472
472
|
action: 'remove',
|
|
473
473
|
});
|
|
474
474
|
});
|
|
475
|
-
|
|
475
|
+
positions.forEach(({ id }) => {
|
|
476
476
|
this.graph.drawTransient('node', id, { action: 'remove' });
|
|
477
477
|
});
|
|
478
478
|
}
|
|
@@ -543,7 +543,7 @@ export class DragNode extends Behavior {
|
|
|
543
543
|
debounce((positions) => {
|
|
544
544
|
// restore the hidden items after move real nodes done
|
|
545
545
|
if (enableTransient) {
|
|
546
|
-
this.clearTransientItems();
|
|
546
|
+
this.clearTransientItems(positions);
|
|
547
547
|
}
|
|
548
548
|
|
|
549
549
|
if (this.options.enableDelegate) {
|
|
@@ -573,7 +573,7 @@ export class DragNode extends Behavior {
|
|
|
573
573
|
return;
|
|
574
574
|
}
|
|
575
575
|
this.clearDelegate();
|
|
576
|
-
this.clearTransientItems();
|
|
576
|
+
this.clearTransientItems(this.originPositions);
|
|
577
577
|
this.restoreHiddenItems();
|
|
578
578
|
|
|
579
579
|
const enableTransient =
|
|
@@ -589,8 +589,8 @@ export class DragNode extends Behavior {
|
|
|
589
589
|
this.clearState();
|
|
590
590
|
}
|
|
591
591
|
|
|
592
|
-
public onDropNode(event: IG6GraphEvent) {
|
|
593
|
-
const elements = this.graph.canvas.document.
|
|
592
|
+
public async onDropNode(event: IG6GraphEvent) {
|
|
593
|
+
const elements = await this.graph.canvas.document.elementsFromPoint(
|
|
594
594
|
event.canvas.x,
|
|
595
595
|
event.canvas.y,
|
|
596
596
|
);
|
|
@@ -640,8 +640,8 @@ export class DragNode extends Behavior {
|
|
|
640
640
|
this.graph.stopHistoryBatch();
|
|
641
641
|
}
|
|
642
642
|
|
|
643
|
-
public onDropCanvas(event: IG6GraphEvent) {
|
|
644
|
-
const elements = this.graph.canvas.document.
|
|
643
|
+
public async onDropCanvas(event: IG6GraphEvent) {
|
|
644
|
+
const elements = await this.graph.canvas.document.elementsFromPoint(
|
|
645
645
|
event.canvas.x,
|
|
646
646
|
event.canvas.y,
|
|
647
647
|
);
|
|
@@ -61,8 +61,10 @@ export class LassoSelect extends BrushSelect {
|
|
|
61
61
|
const { graph, options } = this;
|
|
62
62
|
const { brushStyle } = options;
|
|
63
63
|
return graph.drawTransient('path', LASSO_SHAPE_ID, {
|
|
64
|
-
style:
|
|
65
|
-
|
|
64
|
+
style: {
|
|
65
|
+
pointerEvents: 'none',
|
|
66
|
+
...brushStyle,
|
|
67
|
+
},
|
|
66
68
|
});
|
|
67
69
|
}
|
|
68
70
|
|
|
@@ -82,7 +84,7 @@ export class LassoSelect extends BrushSelect {
|
|
|
82
84
|
|
|
83
85
|
getLassoPath = () => {
|
|
84
86
|
const points: Point[] = this.points;
|
|
85
|
-
const path = [];
|
|
87
|
+
const path: any = [];
|
|
86
88
|
if (points.length) {
|
|
87
89
|
points.forEach((point, index) => {
|
|
88
90
|
if (index === 0) {
|