@antv/g6 5.0.0-beta.31 → 5.0.0-beta.32
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/dist/lib/behaviors/collapse-expand.d.ts +4 -5
- package/dist/lib/behaviors/create-edge.d.ts +55 -0
- package/dist/lib/behaviors/drag-canvas.d.ts +6 -6
- package/dist/lib/behaviors/drag-element.d.ts +5 -3
- package/dist/lib/behaviors/focus-element.d.ts +4 -3
- package/dist/lib/behaviors/hover-element.d.ts +4 -5
- package/dist/lib/behaviors/index.d.ts +2 -0
- package/dist/lib/behaviors/zoom-canvas.d.ts +7 -6
- package/dist/lib/constants/events/graph.d.ts +5 -13
- package/dist/lib/constants/index.d.ts +1 -0
- package/dist/lib/constants/registry.d.ts +20 -0
- package/dist/lib/elements/combos/base-combo.d.ts +21 -0
- package/dist/lib/elements/edges/base-edge.d.ts +21 -0
- package/dist/lib/elements/nodes/base-node.d.ts +22 -1
- package/dist/lib/exports.d.ts +16 -14
- package/dist/lib/plugins/camera-setting.d.ts +95 -0
- package/dist/lib/plugins/contextmenu.d.ts +8 -5
- package/dist/lib/plugins/index.d.ts +4 -0
- package/dist/lib/plugins/legend.d.ts +49 -0
- package/dist/lib/plugins/tooltip.d.ts +12 -10
- package/dist/lib/registry/extension/index.d.ts +2 -2
- package/dist/lib/registry/index.d.ts +6 -4
- package/dist/lib/registry/types.d.ts +0 -6
- package/dist/lib/runtime/canvas.d.ts +2 -1
- package/dist/lib/runtime/data.d.ts +1 -1
- package/dist/lib/runtime/element.d.ts +4 -5
- package/dist/lib/runtime/graph.d.ts +31 -4
- package/dist/lib/runtime/plugin.d.ts +1 -0
- package/dist/lib/types/event.d.ts +42 -7
- package/dist/lib/types/index.d.ts +0 -1
- package/dist/lib/utils/bbox.d.ts +1 -1
- package/dist/lib/utils/element.d.ts +19 -11
- package/dist/lib/utils/event/events.d.ts +8 -13
- package/dist/lib/utils/shortcut.d.ts +10 -0
- package/esm/behaviors/collapse-expand.d.ts +4 -5
- package/esm/behaviors/collapse-expand.js +8 -4
- package/esm/behaviors/collapse-expand.js.map +1 -1
- package/esm/behaviors/create-edge.d.ts +55 -0
- package/esm/behaviors/create-edge.js +141 -0
- package/esm/behaviors/create-edge.js.map +1 -0
- package/esm/behaviors/drag-canvas.d.ts +6 -6
- package/esm/behaviors/drag-canvas.js +15 -7
- package/esm/behaviors/drag-canvas.js.map +1 -1
- package/esm/behaviors/drag-element.d.ts +5 -3
- package/esm/behaviors/drag-element.js.map +1 -1
- package/esm/behaviors/focus-element.d.ts +4 -3
- package/esm/behaviors/focus-element.js.map +1 -1
- package/esm/behaviors/hover-element.d.ts +4 -5
- package/esm/behaviors/hover-element.js.map +1 -1
- package/esm/behaviors/index.d.ts +2 -0
- package/esm/behaviors/index.js +1 -0
- package/esm/behaviors/index.js.map +1 -1
- package/esm/behaviors/zoom-canvas.d.ts +7 -6
- package/esm/behaviors/zoom-canvas.js +6 -2
- package/esm/behaviors/zoom-canvas.js.map +1 -1
- package/esm/constants/events/graph.d.ts +5 -13
- package/esm/constants/events/graph.js +4 -12
- package/esm/constants/events/graph.js.map +1 -1
- package/esm/constants/index.d.ts +1 -0
- package/esm/constants/index.js +1 -0
- package/esm/constants/index.js.map +1 -1
- package/esm/constants/registry.d.ts +20 -0
- package/esm/constants/registry.js +22 -0
- package/esm/constants/registry.js.map +1 -0
- package/esm/elements/combos/base-combo.d.ts +21 -0
- package/esm/elements/combos/base-combo.js +21 -0
- package/esm/elements/combos/base-combo.js.map +1 -1
- package/esm/elements/edges/base-edge.d.ts +21 -0
- package/esm/elements/edges/base-edge.js +21 -0
- package/esm/elements/edges/base-edge.js.map +1 -1
- package/esm/elements/nodes/base-node.d.ts +22 -1
- package/esm/elements/nodes/base-node.js +21 -0
- package/esm/elements/nodes/base-node.js.map +1 -1
- package/esm/exports.d.ts +16 -14
- package/esm/exports.js +7 -6
- package/esm/exports.js.map +1 -1
- package/esm/plugins/camera-setting.d.ts +95 -0
- package/esm/plugins/camera-setting.js +65 -0
- package/esm/plugins/camera-setting.js.map +1 -0
- package/esm/plugins/contextmenu.d.ts +8 -5
- package/esm/plugins/contextmenu.js.map +1 -1
- package/esm/plugins/index.d.ts +4 -0
- package/esm/plugins/index.js +2 -0
- package/esm/plugins/index.js.map +1 -1
- package/esm/plugins/legend.d.ts +49 -0
- package/esm/plugins/legend.js +267 -0
- package/esm/plugins/legend.js.map +1 -0
- package/esm/plugins/tooltip.d.ts +12 -10
- package/esm/plugins/tooltip.js +0 -1
- package/esm/plugins/tooltip.js.map +1 -1
- package/esm/preset.js +2 -5
- package/esm/preset.js.map +1 -1
- package/esm/registry/build-in.js +4 -2
- package/esm/registry/build-in.js.map +1 -1
- package/esm/registry/extension/index.d.ts +2 -2
- package/esm/registry/extension/index.js.map +1 -1
- package/esm/registry/index.d.ts +6 -4
- package/esm/registry/index.js.map +1 -1
- package/esm/registry/types.d.ts +0 -6
- package/esm/runtime/behavior.js +3 -2
- package/esm/runtime/behavior.js.map +1 -1
- package/esm/runtime/canvas.d.ts +2 -1
- package/esm/runtime/canvas.js +68 -30
- package/esm/runtime/canvas.js.map +1 -1
- package/esm/runtime/data.d.ts +1 -1
- package/esm/runtime/element.d.ts +4 -5
- package/esm/runtime/element.js +32 -13
- package/esm/runtime/element.js.map +1 -1
- package/esm/runtime/graph.d.ts +31 -4
- package/esm/runtime/graph.js +48 -9
- package/esm/runtime/graph.js.map +1 -1
- package/esm/runtime/plugin.d.ts +1 -0
- package/esm/runtime/plugin.js +3 -0
- package/esm/runtime/plugin.js.map +1 -1
- package/esm/types/event.d.ts +42 -7
- package/esm/types/index.d.ts +0 -1
- package/esm/utils/bbox.d.ts +1 -1
- package/esm/utils/element.d.ts +19 -11
- package/esm/utils/element.js +19 -9
- package/esm/utils/element.js.map +1 -1
- package/esm/utils/event/events.d.ts +8 -13
- package/esm/utils/event/events.js +3 -8
- package/esm/utils/event/events.js.map +1 -1
- package/esm/utils/shortcut.d.ts +10 -0
- package/esm/utils/shortcut.js +24 -3
- package/esm/utils/shortcut.js.map +1 -1
- package/lib/behaviors/collapse-expand.d.ts +4 -5
- package/lib/behaviors/collapse-expand.js +8 -4
- package/lib/behaviors/collapse-expand.js.map +1 -1
- package/lib/behaviors/create-edge.d.ts +55 -0
- package/lib/behaviors/create-edge.js +145 -0
- package/lib/behaviors/create-edge.js.map +1 -0
- package/lib/behaviors/drag-canvas.d.ts +6 -6
- package/lib/behaviors/drag-canvas.js +15 -7
- package/lib/behaviors/drag-canvas.js.map +1 -1
- package/lib/behaviors/drag-element.d.ts +5 -3
- package/lib/behaviors/drag-element.js.map +1 -1
- package/lib/behaviors/focus-element.d.ts +4 -3
- package/lib/behaviors/focus-element.js.map +1 -1
- package/lib/behaviors/hover-element.d.ts +4 -5
- package/lib/behaviors/hover-element.js.map +1 -1
- package/lib/behaviors/index.d.ts +2 -0
- package/lib/behaviors/index.js +3 -1
- package/lib/behaviors/index.js.map +1 -1
- package/lib/behaviors/zoom-canvas.d.ts +7 -6
- package/lib/behaviors/zoom-canvas.js +6 -2
- package/lib/behaviors/zoom-canvas.js.map +1 -1
- package/lib/constants/events/graph.d.ts +5 -13
- package/lib/constants/events/graph.js +4 -12
- package/lib/constants/events/graph.js.map +1 -1
- package/lib/constants/index.d.ts +1 -0
- package/lib/constants/index.js +1 -0
- package/lib/constants/index.js.map +1 -1
- package/lib/constants/registry.d.ts +20 -0
- package/lib/constants/registry.js +25 -0
- package/lib/constants/registry.js.map +1 -0
- package/lib/elements/combos/base-combo.d.ts +21 -0
- package/lib/elements/combos/base-combo.js +21 -0
- package/lib/elements/combos/base-combo.js.map +1 -1
- package/lib/elements/edges/base-edge.d.ts +21 -0
- package/lib/elements/edges/base-edge.js +21 -0
- package/lib/elements/edges/base-edge.js.map +1 -1
- package/lib/elements/nodes/base-node.d.ts +22 -1
- package/lib/elements/nodes/base-node.js +21 -0
- package/lib/elements/nodes/base-node.js.map +1 -1
- package/lib/exports.d.ts +16 -14
- package/lib/exports.js +23 -1
- package/lib/exports.js.map +1 -1
- package/lib/plugins/camera-setting.d.ts +95 -0
- package/lib/plugins/camera-setting.js +69 -0
- package/lib/plugins/camera-setting.js.map +1 -0
- package/lib/plugins/contextmenu.d.ts +8 -5
- package/lib/plugins/contextmenu.js.map +1 -1
- package/lib/plugins/index.d.ts +4 -0
- package/lib/plugins/index.js +5 -1
- package/lib/plugins/index.js.map +1 -1
- package/lib/plugins/legend.d.ts +49 -0
- package/lib/plugins/legend.js +271 -0
- package/lib/plugins/legend.js.map +1 -0
- package/lib/plugins/tooltip.d.ts +12 -10
- package/lib/plugins/tooltip.js +0 -1
- package/lib/plugins/tooltip.js.map +1 -1
- package/lib/preset.js +2 -5
- package/lib/preset.js.map +1 -1
- package/lib/registry/build-in.js +2 -0
- package/lib/registry/build-in.js.map +1 -1
- package/lib/registry/extension/index.d.ts +2 -2
- package/lib/registry/extension/index.js.map +1 -1
- package/lib/registry/index.d.ts +6 -4
- package/lib/registry/index.js.map +1 -1
- package/lib/registry/types.d.ts +0 -6
- package/lib/runtime/behavior.js +3 -2
- package/lib/runtime/behavior.js.map +1 -1
- package/lib/runtime/canvas.d.ts +2 -1
- package/lib/runtime/canvas.js +68 -30
- package/lib/runtime/canvas.js.map +1 -1
- package/lib/runtime/data.d.ts +1 -1
- package/lib/runtime/element.d.ts +4 -5
- package/lib/runtime/element.js +31 -12
- package/lib/runtime/element.js.map +1 -1
- package/lib/runtime/graph.d.ts +31 -4
- package/lib/runtime/graph.js +47 -8
- package/lib/runtime/graph.js.map +1 -1
- package/lib/runtime/plugin.d.ts +1 -0
- package/lib/runtime/plugin.js +3 -0
- package/lib/runtime/plugin.js.map +1 -1
- package/lib/types/event.d.ts +42 -7
- package/lib/types/index.d.ts +0 -1
- package/lib/utils/bbox.d.ts +1 -1
- package/lib/utils/element.d.ts +19 -11
- package/lib/utils/element.js +21 -10
- package/lib/utils/element.js.map +1 -1
- package/lib/utils/event/events.d.ts +8 -13
- package/lib/utils/event/events.js +4 -10
- package/lib/utils/event/events.js.map +1 -1
- package/lib/utils/shortcut.d.ts +10 -0
- package/lib/utils/shortcut.js +24 -3
- package/lib/utils/shortcut.js.map +1 -1
- package/package.json +2 -2
- package/src/behaviors/collapse-expand.ts +13 -11
- package/src/behaviors/create-edge.ts +206 -0
- package/src/behaviors/drag-canvas.ts +22 -14
- package/src/behaviors/drag-element.ts +8 -11
- package/src/behaviors/focus-element.ts +7 -6
- package/src/behaviors/hover-element.ts +14 -10
- package/src/behaviors/index.ts +2 -0
- package/src/behaviors/zoom-canvas.ts +14 -9
- package/src/constants/events/graph.ts +4 -12
- package/src/constants/index.ts +1 -0
- package/src/constants/registry.ts +20 -0
- package/src/elements/combos/base-combo.ts +24 -0
- package/src/elements/edges/base-edge.ts +25 -1
- package/src/elements/nodes/base-node.ts +25 -1
- package/src/exports.ts +55 -12
- package/src/plugins/camera-setting.ts +153 -0
- package/src/plugins/contextmenu.ts +10 -7
- package/src/plugins/index.ts +4 -0
- package/src/plugins/legend.ts +321 -0
- package/src/plugins/tooltip.ts +16 -15
- package/src/preset.ts +2 -6
- package/src/registry/build-in.ts +12 -2
- package/src/registry/extension/index.ts +4 -4
- package/src/registry/index.ts +10 -4
- package/src/registry/types.ts +0 -7
- package/src/runtime/behavior.ts +3 -2
- package/src/runtime/canvas.ts +80 -40
- package/src/runtime/element.ts +52 -20
- package/src/runtime/graph.ts +56 -12
- package/src/runtime/plugin.ts +4 -0
- package/src/types/event.ts +62 -7
- package/src/types/index.ts +0 -1
- package/src/utils/bbox.ts +1 -1
- package/src/utils/element.ts +22 -11
- package/src/utils/event/events.ts +15 -17
- package/src/utils/shortcut.ts +28 -3
- package/dist/lib/types/behavior.d.ts +0 -5
- package/esm/types/behavior.d.ts +0 -5
- package/esm/types/behavior.js +0 -2
- package/esm/types/behavior.js.map +0 -1
- package/lib/types/behavior.d.ts +0 -5
- package/lib/types/behavior.js +0 -3
- package/lib/types/behavior.js.map +0 -1
- package/src/types/behavior.ts +0 -6
package/src/types/event.ts
CHANGED
|
@@ -1,11 +1,66 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import type {
|
|
2
|
+
DisplayObject,
|
|
3
|
+
Document,
|
|
4
|
+
FederatedEvent,
|
|
5
|
+
FederatedPointerEvent,
|
|
6
|
+
FederatedWheelEvent,
|
|
7
|
+
IAnimation,
|
|
8
|
+
} from '@antv/g';
|
|
9
|
+
import type { AnimationType } from '../constants';
|
|
10
|
+
import type { ElementDatum } from './data';
|
|
11
|
+
import type { Element, ElementType } from './element';
|
|
12
|
+
import type { TransformOptions } from './viewport';
|
|
4
13
|
|
|
5
|
-
export type
|
|
14
|
+
export type IEvent =
|
|
15
|
+
| IGraphLifeCycleEvent
|
|
16
|
+
| IAnimateEvent
|
|
17
|
+
| IElementLifeCycleEvent
|
|
18
|
+
| IViewportEvent
|
|
19
|
+
| IPointerEvent
|
|
20
|
+
| IWheelEvent
|
|
21
|
+
| IKeyboardEvent
|
|
22
|
+
| IDragEvent;
|
|
6
23
|
|
|
7
|
-
export
|
|
24
|
+
export interface IPointerEvent<T extends Target = Target> extends TargetedEvent<FederatedPointerEvent, T> {}
|
|
8
25
|
|
|
9
|
-
export interface
|
|
10
|
-
|
|
26
|
+
export interface IWheelEvent<T extends Target = Target> extends TargetedEvent<FederatedWheelEvent, T> {}
|
|
27
|
+
|
|
28
|
+
export interface IKeyboardEvent extends KeyboardEvent {}
|
|
29
|
+
|
|
30
|
+
export interface IDragEvent<T extends Target = Target> extends TargetedEvent<FederatedPointerEvent, T> {
|
|
31
|
+
dx: number;
|
|
32
|
+
dy: number;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export interface IGraphLifeCycleEvent extends NativeEvent {
|
|
36
|
+
data?: any;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export interface IElementLifeCycleEvent extends NativeEvent {
|
|
40
|
+
elementType: ElementType;
|
|
41
|
+
data: ElementDatum;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export interface IViewportEvent extends NativeEvent {
|
|
45
|
+
data: TransformOptions;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export interface IAnimateEvent extends NativeEvent {
|
|
49
|
+
animationType: AnimationType;
|
|
50
|
+
animation: IAnimation | null;
|
|
51
|
+
data?: any;
|
|
11
52
|
}
|
|
53
|
+
|
|
54
|
+
/** <zh/> G6 原生事件 | <en/> G6 native event */
|
|
55
|
+
interface NativeEvent {
|
|
56
|
+
type: string;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/** <zh/> 具有目标的事件 | <en/> Event with target */
|
|
60
|
+
type TargetedEvent<E extends FederatedEvent, T extends Target = Target> = Omit<E, 'target'> & {
|
|
61
|
+
originalTarget: DisplayObject;
|
|
62
|
+
target: T;
|
|
63
|
+
targetType: 'canvas' | 'node' | 'edge' | 'combo';
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
export type Target = Document | Element;
|
package/src/types/index.ts
CHANGED
package/src/utils/bbox.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { AABB } from '@antv/g';
|
|
2
2
|
import { clone } from '@antv/util';
|
|
3
|
-
import { TriangleDirection } from '../elements/nodes/triangle';
|
|
3
|
+
import type { TriangleDirection } from '../elements/nodes/triangle';
|
|
4
4
|
import type { Node, Padding, Point } from '../types';
|
|
5
5
|
import { isPoint } from './is';
|
|
6
6
|
import { isBetween } from './math';
|
package/src/utils/element.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type { AABB, DisplayObject, TextStyleProps } from '@antv/g';
|
|
2
2
|
import { get, isString } from '@antv/util';
|
|
3
3
|
import { BaseCombo, BaseEdge, BaseNode } from '../elements';
|
|
4
|
-
import { NodePortStyleProps } from '../elements/nodes/base-node';
|
|
4
|
+
import type { NodePortStyleProps } from '../elements/nodes/base-node';
|
|
5
5
|
import type { TriangleDirection } from '../elements/nodes/triangle';
|
|
6
|
-
import type { Combo, Edge, Node, Placement, Point, Position } from '../types';
|
|
6
|
+
import type { Combo, Edge, Element, Node, Placement, Point, Position } from '../types';
|
|
7
7
|
import type { LabelPlacement, Port } from '../types/node';
|
|
8
8
|
import { getBBoxHeight, getBBoxWidth } from './bbox';
|
|
9
9
|
import { isPoint } from './is';
|
|
@@ -11,38 +11,49 @@ import { findNearestPoints, getEllipseIntersectPoint } from './point';
|
|
|
11
11
|
import { getXYByPlacement } from './position';
|
|
12
12
|
|
|
13
13
|
/**
|
|
14
|
-
* <zh/> 判断是否是
|
|
14
|
+
* <zh/> 判断是否是 Node 的实例
|
|
15
15
|
*
|
|
16
|
-
* <en/> Judge whether the instance is
|
|
16
|
+
* <en/> Judge whether the instance is Node
|
|
17
17
|
* @param shape - <zh/> 实例 | <en/> instance
|
|
18
|
-
* @returns <zh/> 是否是
|
|
18
|
+
* @returns <zh/> 是否是 Node 的实例 | <en/> whether the instance is Node
|
|
19
19
|
*/
|
|
20
20
|
export function isNode(shape: DisplayObject | Port): shape is Node {
|
|
21
21
|
return shape instanceof BaseNode && shape.type === 'node';
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
/**
|
|
25
|
-
* <zh/> 判断是否是
|
|
25
|
+
* <zh/> 判断是否是 Edge 的实例
|
|
26
26
|
*
|
|
27
|
-
* <en/> Judge whether the instance is
|
|
27
|
+
* <en/> Judge whether the instance is Edge
|
|
28
28
|
* @param shape - <zh/> 实例 | <en/> instance
|
|
29
|
-
* @returns <zh/> 是否是
|
|
29
|
+
* @returns <zh/> 是否是 Edge 的实例 | <en/> whether the instance is Edge
|
|
30
30
|
*/
|
|
31
31
|
export function isEdge(shape: DisplayObject): shape is Edge {
|
|
32
32
|
return shape instanceof BaseEdge;
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
/**
|
|
36
|
-
* <zh/> 判断是否是
|
|
36
|
+
* <zh/> 判断是否是 Combo 的实例
|
|
37
37
|
*
|
|
38
|
-
* <en/> Judge whether the instance is
|
|
38
|
+
* <en/> Judge whether the instance is Combo
|
|
39
39
|
* @param shape - <zh/> 实例 | <en/> instance
|
|
40
|
-
* @returns <zh/> 是否是
|
|
40
|
+
* @returns <zh/> 是否是 Combo 的实例 | <en/> whether the instance is Combo
|
|
41
41
|
*/
|
|
42
42
|
export function isCombo(shape: DisplayObject): shape is Combo {
|
|
43
43
|
return shape instanceof BaseCombo;
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
+
/**
|
|
47
|
+
* <zh/> 判断是否是 Element 的实例
|
|
48
|
+
*
|
|
49
|
+
* <en/> Judge whether the instance is Element
|
|
50
|
+
* @param shape - <zh/> 实例 | <en/> instance
|
|
51
|
+
* @returns <zh/> 是否是 Element 的实例 | <en/> whether the instance is Element
|
|
52
|
+
*/
|
|
53
|
+
export function isElement(shape: any): shape is Element {
|
|
54
|
+
return isNode(shape) || isEdge(shape) || isCombo(shape);
|
|
55
|
+
}
|
|
56
|
+
|
|
46
57
|
/**
|
|
47
58
|
* <zh/> 判断两个节点是否相同
|
|
48
59
|
*
|
|
@@ -1,14 +1,20 @@
|
|
|
1
1
|
import type { IAnimation } from '@antv/g';
|
|
2
|
-
import type { ID } from '@antv/graphlib';
|
|
3
2
|
import type { AnimationType, GraphEvent } from '../../constants';
|
|
4
|
-
import type {
|
|
5
|
-
|
|
3
|
+
import type {
|
|
4
|
+
ElementDatum,
|
|
5
|
+
ElementType,
|
|
6
|
+
IAnimateEvent,
|
|
7
|
+
IElementLifeCycleEvent,
|
|
8
|
+
IGraphLifeCycleEvent,
|
|
9
|
+
IViewportEvent,
|
|
10
|
+
TransformOptions,
|
|
11
|
+
} from '../../types';
|
|
6
12
|
|
|
7
13
|
export class BaseEvent {
|
|
8
14
|
constructor(public type: string) {}
|
|
9
15
|
}
|
|
10
16
|
|
|
11
|
-
export class GraphLifeCycleEvent extends BaseEvent {
|
|
17
|
+
export class GraphLifeCycleEvent extends BaseEvent implements IGraphLifeCycleEvent {
|
|
12
18
|
constructor(
|
|
13
19
|
type:
|
|
14
20
|
| GraphEvent.BEFORE_RENDER
|
|
@@ -25,7 +31,7 @@ export class GraphLifeCycleEvent extends BaseEvent {
|
|
|
25
31
|
}
|
|
26
32
|
}
|
|
27
33
|
|
|
28
|
-
export class AnimateEvent extends BaseEvent {
|
|
34
|
+
export class AnimateEvent extends BaseEvent implements IAnimateEvent {
|
|
29
35
|
constructor(
|
|
30
36
|
type: GraphEvent.BEFORE_ANIMATE | GraphEvent.AFTER_ANIMATE,
|
|
31
37
|
public animationType: AnimationType,
|
|
@@ -36,7 +42,7 @@ export class AnimateEvent extends BaseEvent {
|
|
|
36
42
|
}
|
|
37
43
|
}
|
|
38
44
|
|
|
39
|
-
export class ElementLifeCycleEvent extends BaseEvent {
|
|
45
|
+
export class ElementLifeCycleEvent extends BaseEvent implements IElementLifeCycleEvent {
|
|
40
46
|
constructor(
|
|
41
47
|
type:
|
|
42
48
|
| GraphEvent.BEFORE_ELEMENT_CREATE
|
|
@@ -45,13 +51,14 @@ export class ElementLifeCycleEvent extends BaseEvent {
|
|
|
45
51
|
| GraphEvent.AFTER_ELEMENT_UPDATE
|
|
46
52
|
| GraphEvent.BEFORE_ELEMENT_DESTROY
|
|
47
53
|
| GraphEvent.AFTER_ELEMENT_DESTROY,
|
|
48
|
-
public
|
|
54
|
+
public elementType: ElementType,
|
|
55
|
+
public data: ElementDatum,
|
|
49
56
|
) {
|
|
50
57
|
super(type);
|
|
51
58
|
}
|
|
52
59
|
}
|
|
53
60
|
|
|
54
|
-
export class ViewportEvent extends BaseEvent {
|
|
61
|
+
export class ViewportEvent extends BaseEvent implements IViewportEvent {
|
|
55
62
|
constructor(
|
|
56
63
|
type: GraphEvent.BEFORE_TRANSFORM | GraphEvent.AFTER_TRANSFORM,
|
|
57
64
|
public data: TransformOptions,
|
|
@@ -59,12 +66,3 @@ export class ViewportEvent extends BaseEvent {
|
|
|
59
66
|
super(type);
|
|
60
67
|
}
|
|
61
68
|
}
|
|
62
|
-
|
|
63
|
-
export class ElementStateChangeEvent extends BaseEvent {
|
|
64
|
-
constructor(
|
|
65
|
-
type: GraphEvent.BEFORE_ELEMENT_STATE_CHANGE | GraphEvent.AFTER_ELEMENT_STATE_CHANGE,
|
|
66
|
-
public states: Record<ID, State | State[]>,
|
|
67
|
-
) {
|
|
68
|
-
super(type);
|
|
69
|
-
}
|
|
70
|
-
}
|
package/src/utils/shortcut.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import EventEmitter from '@antv/event-emitter';
|
|
2
|
+
import type { FederatedMouseEvent } from '@antv/g';
|
|
2
3
|
import { isEqual } from '@antv/util';
|
|
3
4
|
import { CommonEvent } from '../constants';
|
|
4
5
|
|
|
@@ -43,6 +44,7 @@ export class Shortcut {
|
|
|
43
44
|
emitter.on(CommonEvent.KEY_DOWN, this.onKeyDown);
|
|
44
45
|
emitter.on(CommonEvent.KEY_UP, this.onKeyUp);
|
|
45
46
|
emitter.on(CommonEvent.WHEEL, this.onWheel);
|
|
47
|
+
emitter.on(CommonEvent.DRAG, this.onDrag);
|
|
46
48
|
}
|
|
47
49
|
|
|
48
50
|
private onKeyDown = (event: KeyboardEvent) => {
|
|
@@ -60,18 +62,41 @@ export class Shortcut {
|
|
|
60
62
|
});
|
|
61
63
|
}
|
|
62
64
|
|
|
63
|
-
|
|
65
|
+
/**
|
|
66
|
+
* <zh/> 扩展 wheel, drag 操作
|
|
67
|
+
*
|
|
68
|
+
* <en/> Extend wheel, drag operations
|
|
69
|
+
* @param eventType - event name
|
|
70
|
+
* @param event - event
|
|
71
|
+
*/
|
|
72
|
+
private triggerExtendKey(eventType: CommonEvent, event: unknown) {
|
|
64
73
|
this.map.forEach((handler, key) => {
|
|
65
|
-
if (key.includes(
|
|
74
|
+
if (key.includes(eventType)) {
|
|
66
75
|
if (
|
|
67
76
|
isEqual(
|
|
68
77
|
Array.from(this.recordKey),
|
|
69
|
-
key.filter((k) => k !==
|
|
78
|
+
key.filter((k) => k !== eventType),
|
|
70
79
|
)
|
|
71
80
|
) {
|
|
72
81
|
handler(event);
|
|
73
82
|
}
|
|
74
83
|
}
|
|
75
84
|
});
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
private onWheel = (event: WheelEvent) => {
|
|
88
|
+
this.triggerExtendKey(CommonEvent.WHEEL, event);
|
|
76
89
|
};
|
|
90
|
+
|
|
91
|
+
private onDrag = (event: FederatedMouseEvent) => {
|
|
92
|
+
this.triggerExtendKey(CommonEvent.DRAG, event);
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
public destroy() {
|
|
96
|
+
this.unbindAll();
|
|
97
|
+
this.emitter.off(CommonEvent.KEY_DOWN, this.onKeyDown);
|
|
98
|
+
this.emitter.off(CommonEvent.KEY_UP, this.onKeyUp);
|
|
99
|
+
this.emitter.off(CommonEvent.WHEEL, this.onWheel);
|
|
100
|
+
this.emitter.off(CommonEvent.DRAG, this.onDrag);
|
|
101
|
+
}
|
|
77
102
|
}
|
package/esm/types/behavior.d.ts
DELETED
package/esm/types/behavior.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"behavior.js","sourceRoot":"src/","sources":["types/behavior.ts"],"names":[],"mappings":""}
|
package/lib/types/behavior.d.ts
DELETED
package/lib/types/behavior.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"behavior.js","sourceRoot":"src/","sources":["types/behavior.ts"],"names":[],"mappings":""}
|
package/src/types/behavior.ts
DELETED