suoqiu-f2
Version:
Charts for mobile visualization.
96 lines (93 loc) • 3.3 kB
JavaScript
;
exports.__esModule = true;
exports["default"] = void 0;
var _common = require("../util/common");
var _base = _interopRequireDefault(require("./base"));
var _chart = _interopRequireDefault(require("../chart/chart"));
var _move = _interopRequireDefault(require("./mixin/move"));
var _updateScale = _interopRequireDefault(require("./mixin/update-scale"));
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
function _inheritsLoose(t, o) { t.prototype = Object.create(o.prototype), t.prototype.constructor = t, _setPrototypeOf(t, o); }
function _setPrototypeOf(t, e) { return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) { return t.__proto__ = e, t; }, _setPrototypeOf(t, e); } // import * as FilterPlugin from '../plugin/filter';
var Pan = /*#__PURE__*/function (_Interaction) {
function Pan(cfg, chart) {
var _this;
_this = _Interaction.call(this, cfg, chart) || this;
var self = _this;
var hammer = self.hammer,
panThreshold = self.panThreshold;
chart.set('limitInPlot', true);
if (hammer) {
hammer.get('pan').set({
threshold: panThreshold
});
// 为了兼容hammer的pan 和 tooltips里的press, 后面去hammerjs的时候需要去掉
chart.get('canvas').on('pan', function () {});
}
// chart.registerPlugins([ FilterPlugin, {
// changeData() {
// self.limitRange = {};
// },
// clear() {
// self.limitRange = {};
// }
// }]);
(0, _common.mix)(_this, _updateScale["default"], _move["default"]);
return _this;
}
_inheritsLoose(Pan, _Interaction);
var _proto = Pan.prototype;
_proto.getDefaultCfg = function getDefaultCfg() {
var defaultCfg = _Interaction.prototype.getDefaultCfg.call(this);
defaultCfg = (0, _common.mix)({}, defaultCfg, {
startEvent: 'panstart',
processEvent: 'panmove',
endEvent: 'panend',
resetEvent: 'touchend',
mode: 'x',
panThreshold: 10,
// Minimal pan distance required before recognizing
pressThreshold: 9,
// Minimal movement that is allowed while pressing
pressTime: 251,
// Minimal press time in ms
currentDeltaX: null,
currentDeltaY: null,
limitRange: {},
_timestamp: 0,
lastPoint: null,
_panCumulativeDelta: 0,
speed: 5
});
if (_common.isWx || _common.isMy) {
// 小程序
defaultCfg.startEvent = 'touchstart';
defaultCfg.processEvent = 'touchmove';
defaultCfg.endEvent = 'touchend';
}
return defaultCfg;
};
_proto.start = function start(e) {
if (this.pressed) return;
this.currentDeltaX = 0;
this.currentDeltaY = 0;
if (e.type === 'touchstart' || e.type === 'touchStart') {
this.lastPoint = e.touches[0];
}
// this._handleMove(e);
};
_proto.process = function process(e) {
if (this.pressed) return;
this._handleMove(e);
};
_proto.end = function end() {
if (this.pressed) return;
this.currentDeltaX = null;
this.currentDeltaY = null;
this.lastPoint = null;
this._panCumulativeDelta = 0;
};
return Pan;
}(_base["default"]);
_chart["default"].registerInteraction('pan', Pan);
var _default = exports["default"] = Pan;