"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = void 0;

var _util = require("@antv/util");

var _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;
    (0, _util.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;
    (0, _util.each)(events, function (handler, event) {
      graph.off(event, handler);
    });
  }
};
exports.default = _default;