@antv/interaction
The interaction module for antv
Last updated 7 years ago by dxq613 .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ npm install @antv/interaction 
SYNC missed versions from official npm registry.

Interaction

使用

import { registerInteraction, createInteraction} from '@antv/interaction';
registerInteraction('my-interaction', {
  start: [
    {trigger: 'mouseenter', action: 'element-active:active'}
  ]
});

const interaction = createInteraction('my-interaction'); 
interaction.bind(chart);
interaction.unbind(chart);
interaction.destroy();

API

Interaction

构造函数:

// 用户可以定义自己的 Context 
new Interaction(new Context(), steps);

方法有:

  • bind(source: EventEmitter) 绑定事件源
  • unbind(source: EventEmitter) 解除事件源绑定
  • destroy() 销毁

Context

提供了 IContext 接口,其定义为:

/** 交互上下文的接口定义 */
export interface IInteractionContext {
  /** 事件对象 */
  event: LooseObject;
  /**
   * 当前的触发源
   */
  source: EventEmiter;

  /** 交互相关的 Actions */
  actions: IAction[];
  /**
   * 缓存属性,用于上下文传递信息
   * @param key 键名
   * @param value 值
   */
  cache(key: string, value?: any);
  /**
   * 获取 action
   * @param name - action 的名称
   * @returns 指定 name 的 Action
   */
  getAction(name): IAction;
  /**
   * 添加 action
   * @param action 指定交互 action
   */
  addAction(action: IAction);
  /**
   * 移除 action
   * @param action 移除的 action
   */
  removeAction(action: IAction);
  /**
   * 销毁
   */
  destroy();
}

Current Tags

  • 0.2.0-beta.2                                ...           beta (7 years ago)
  • 0.1.5                                ...           latest (8 years ago)

16 Versions

  • 0.2.0-beta.2                                ...           7 years ago
  • 0.2.0-beta.1                                ...           7 years ago
  • 0.1.5                                ...           8 years ago
  • 0.1.4                                ...           8 years ago
  • 0.1.3                                ...           8 years ago
  • 0.1.2                                ...           8 years ago
  • 0.1.1                                ...           8 years ago
  • 0.1.0                                ...           8 years ago
  • 0.0.8                                ...           8 years ago
  • 0.0.7                                ...           8 years ago
  • 0.0.6                                ...           8 years ago
  • 0.0.5                                ...           8 years ago
  • 0.0.4                                ...           8 years ago
  • 0.0.3                                ...           8 years ago
  • 0.0.2                                ...           8 years ago
  • 0.0.1                                ...           8 years ago
Downloads
Total 19
Today 0
This Week 0
This Month 17
Last Day 0
Last Week 1
Last Month 0
Dependencies (3)
Dev Dependencies (12)
Dependents (1)

© 2010 - cnpmjs.org x YWFE | Home | YWFE