import { each } from '@antv/util';
export default {
  /**
   * auto bind events when register behavior
   * @param graph Graph instance
   */
  bind: function bind(graph) {
    if (this.type === 'drag-canvas') {
      graph.get('canvas').set('draggable', true);
    }

    var events = this.events;
    this.graph = graph;
    each(events, function (handler, event) {
      graph.on(event, handler);
    });
  },
  unbind: function unbind(graph) {
    var events = this.events;

    if (this.type === 'drag-canvas') {
      graph.get('canvas').set('draggable', false);
    }

    this.graph = null;
    each(events, function (handler, event) {
      graph.off(event, handler);
    });
  }
};