'use strict';

Object.defineProperty(exports, "__esModule", {
  value: true
});

var _classCallCheck2 = require('babel-runtime/helpers/classCallCheck');

var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);

var _createClass2 = require('babel-runtime/helpers/createClass');

var _createClass3 = _interopRequireDefault(_createClass2);

var _methodsUtil = require('../../_util/methods-util');

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }

var DragPan = function () {
  function DragPan(iMapApi) {
    (0, _classCallCheck3['default'])(this, DragPan);

    this.iMapApi = iMapApi;
    // 获取原地图的dragPan对象
    var map = this.iMapApi && this.iMapApi.map;
    if (map) {
      this.dragPan = map.dragPan;
    }
  }

  /**
   * 激活地图漫游交互功能
   * @param {Object} options 漫游交互的选项
   */


  (0, _createClass3['default'])(DragPan, [{
    key: 'enable',
    value: function enable() {
      var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};

      var cursor = this.iMapApi && this.iMapApi.Handlers && this.iMapApi.Handlers.cursor;
      // 判断当前地图的光标是否有关联的交互对象
      if (!(0, _methodsUtil.isBooleanTrue)(options.silent)) {
        cursor && cursor.handler && (0, _methodsUtil.isFunction)(cursor.handler.disable) && cursor.handler.disable();
      }
      // 触发地图漫游激活
      this.dragPan && this.dragPan.enable(options);
    }

    /**
     * 禁用地图漫游交互功能
     */

  }, {
    key: 'disable',
    value: function disable() {
      this.dragPan && this.dragPan.disable();
    }

    /**
     * 获取地图漫游交互当前的禁用/启用状态
     */

  }, {
    key: 'isEnabled',
    value: function isEnabled() {
      if (!this.dragPan) {
        return;
      }
      return this.dragPan.isEnabled();
    }

    /**
     * 获取地图漫游交互当前的活动状态
     */

  }, {
    key: 'isActive',
    value: function isActive() {
      if (!this.dragPan) {
        return;
      }
      return this.dragPan.isActive();
    }
  }]);
  return DragPan;
}(); /**
      * @文件说明: Handlers.DragPan 地图漫游交互
      * @创建人: pjtools@vip.qq.com
      * @创建时间: 2020-05-14 14:08:40
      */

exports['default'] = DragPan;