UNPKG

1.55 kBTypeScriptView Raw
1import { View } from '../chart';
2import { IShape, Point } from '../dependents';
3import { IAction, IInteractionContext, LooseObject } from '../interface';
4/**
5 * 交互的上下文
6 */
7export default class Context implements IInteractionContext {
8 /** 当前所有的 Action */
9 actions: IAction[];
10 /** 当前 View 实例 */
11 view: View;
12 /** 当前事件对象 */
13 event: LooseObject;
14 private cacheMap;
15 constructor(view: View);
16 /**
17 * 缓存信息
18 * @param params 缓存的字段
19 * - 如果一个字段则获取缓存
20 * - 两个字段则设置缓存
21 */
22 cache(...params: any[]): any;
23 /**
24 * 获取 Action
25 * @param name Action 的名称
26 */
27 getAction(name: string): IAction;
28 /**
29 * 获取 Action
30 * @param action Action 对象
31 */
32 addAction(action: IAction): void;
33 /**
34 * 移除 Action
35 * @param action Action 对象
36 */
37 removeAction(action: IAction): void;
38 /**
39 * 获取当前的点
40 */
41 getCurrentPoint(): Point;
42 /**
43 * 获取当前 shape
44 * @returns current shape
45 */
46 getCurrentShape(): IShape;
47 /**
48 * 当前的触发是否在 View 内
49 */
50 isInPlot(): boolean;
51 /**
52 * 是否在指定的图形内
53 * @param name shape 的 name
54 */
55 isInShape(name: any): boolean;
56 /**
57 * 当前的触发是组件内部
58 * @param name 组件名,可以为空
59 */
60 isInComponent(name?: string): boolean;
61 /**
62 * 销毁
63 */
64 destroy(): void;
65}