text: import { __extends } from "tslib";
  import EE from '@antv/event-emitter';
  import { getGesture } from './gestures';
  /**
   * 给 view 添加移动端的滚动能力：
   *  - 监听 touch 事件，emit wheel 事件
   *  - 滚动惯性包装
   *  - 和 pc 的 wheel 事件保持基本一致
   */
  var GM = /** @class */ (function (_super) {
      __extends(GM, _super);
      function GM(element, options) {
          if (options === void 0) { options = {}; }
          var _this = _super.call(this) || this;
          /**
           * touchstart 触发
           * @param ev
           */
          _this.onTouchStart = function (ev) {
              _this.preventEvent(ev);
              _this.element.on('touchmove', _this.onTouchMove);
              _this.element.on('touchend', _this.onTouchEnd);
              _this.element.on('touchcancel', _this.onTouchCancel);
              _this.emit('touchdown', ev);
              _this.doGestures(ev);
          };
          /**
           * touchmove 触发
           * @param ev
           */
          _this.onTouchMove = function (ev) {
              _this.preventEvent(ev);
              _this.emit('touchmove', ev);
              _this.doGestures(ev);
          };
          /**
           * touchend 触发
           * @param ev
           */
          _this.onTouchEnd = function (ev) {
              _this.preventEvent(ev);
              _this.emit('touchend', ev);
              _this.element.off('touchmove', _this.onTouchMove);
              _this.element.off('touchend', _this.onTouchEnd);
              _this.element.off('touchcancel', _this.onTouchCancel);
              _this.doGestures(ev);
          };
          /**
           * touchcancel 触发
           * @param ev
           */
          _this.onTouchCancel = function (ev) {
              _this.preventEvent(ev);
              _this.emit('touchcancel', ev);
              _this.element.off('touchmove', _this.onTouchMove);
              _this.element.off('touchend', _this.onTouchEnd);
              _this.element.off('touchcancel', _this.onTouchCancel);
              _this.doGestures(ev);
          };
          _this.element = element;
          _this.options = options;
          _this.initialGestures();
          _this.bindTouchStart();
          return _this;
      }
      /**
       * 销毁，取消事件绑定
       */
      GM.prototype.destroy = function () {
          this.element.off('touchstart', this.onTouchStart);
          this.off();
      };
      /**
       * 实例化手势
       */
      GM.prototype.initialGestures = function () {
          var _this = this;
          var gestures = this.options.gestures || ['Pan', 'Press', 'Swipe', 'Tap'];
          this.gestures = gestures.map(function (gesture) {
              var Ctor = getGesture(gesture);
              return new Ctor(_this);
          });
      };
      /**
       * 绑定 touchstart 事件
       */
      GM.prototype.bindTouchStart = function () {
          this.element.on('touchstart', this.onTouchStart);
      };
      GM.prototype.preventEvent = function (ev) {
          var type = ev.type;
          var prevents = this.options.prevents || [];
          if (prevents.includes(type)) {
              ev.preventDefault();
          }
      };
      GM.prototype.doGestures = function (ev) {
          this.gestures.forEach(function (g) {
              g.do(ev);
          });
      };
      return GM;
  }(EE));
  export { GM };
  //# sourceMappingURL=gm.js.map