-
Notifications
You must be signed in to change notification settings - Fork 1.3k
/
behavior-drag-element.ts
48 lines (44 loc) · 1.36 KB
/
behavior-drag-element.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import { Graph } from '@/src';
import type { STDTestCase } from '../types';
export const behaviorDragNode: STDTestCase = async (context) => {
const graph = new Graph({
...context,
data: {
nodes: [
{ id: 'node-1', style: { x: 100, y: 100 } },
{ id: 'node-2', style: { x: 200, y: 100, parentId: 'combo-1' } },
{ id: 'node-3', style: { x: 100, y: 200 } },
{ id: 'node-4', style: { x: 200, y: 200, parentId: 'combo-1' } },
],
edges: [
{ source: 'node-1', target: 'node-2' },
{ source: 'node-2', target: 'node-4' },
{ source: 'node-1', target: 'node-3' },
{ source: 'node-3', target: 'node-4' },
],
combos: [{ id: 'combo-1' }],
},
node: { style: { size: 20 } },
edge: {
style: { endArrow: true },
},
behaviors: [{ type: 'drag-element' }],
});
await graph.render();
behaviorDragNode.form = (panel) => {
const config = {
enable: true,
hideEdges: 'none',
shadow: false,
};
const handleChange = () => {
graph.setBehaviors([{ type: 'drag-element', ...config }]);
};
return [
panel.add(config, 'enable').onChange(handleChange),
panel.add(config, 'hideEdges', ['none', 'in', 'out', 'both']).onChange(handleChange),
panel.add(config, 'shadow').onChange(handleChange),
];
};
return graph;
};