1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | var tslib_1 = require("tslib");
|
4 | var matrix_util_1 = require("@antv/matrix-util");
|
5 | var __1 = require("..");
|
6 | var util_1 = require("../util");
|
7 | var MIN_DISTANCE = 5;
|
8 |
|
9 |
|
10 |
|
11 |
|
12 | var Move = (function (_super) {
|
13 | tslib_1.__extends(Move, _super);
|
14 | function Move() {
|
15 | var _this = _super !== null && _super.apply(this, arguments) || this;
|
16 | _this.starting = false;
|
17 | _this.isMoving = false;
|
18 |
|
19 | _this.startPoint = null;
|
20 | _this.startMatrix = null;
|
21 | return _this;
|
22 | }
|
23 | |
24 |
|
25 |
|
26 | Move.prototype.start = function () {
|
27 | this.starting = true;
|
28 | this.startPoint = this.context.getCurrentPoint();
|
29 |
|
30 | this.startMatrix = this.context.view.middleGroup.getMatrix();
|
31 | };
|
32 | |
33 |
|
34 |
|
35 | Move.prototype.move = function () {
|
36 | if (!this.starting) {
|
37 | return;
|
38 | }
|
39 | var startPoint = this.startPoint;
|
40 | var currentPoint = this.context.getCurrentPoint();
|
41 | var d = util_1.distance(startPoint, currentPoint);
|
42 | if (d > MIN_DISTANCE && !this.isMoving) {
|
43 | this.isMoving = true;
|
44 | }
|
45 | if (this.isMoving) {
|
46 | var view = this.context.view;
|
47 | var matrix = matrix_util_1.ext.transform(this.startMatrix, [
|
48 | ['t', currentPoint.x - startPoint.x, currentPoint.y - startPoint.y],
|
49 | ]);
|
50 | view.backgroundGroup.setMatrix(matrix);
|
51 | view.foregroundGroup.setMatrix(matrix);
|
52 | view.middleGroup.setMatrix(matrix);
|
53 | }
|
54 | };
|
55 | |
56 |
|
57 |
|
58 | Move.prototype.end = function () {
|
59 | if (this.isMoving) {
|
60 | this.isMoving = false;
|
61 | }
|
62 | this.startMatrix = null;
|
63 | this.starting = false;
|
64 | this.startPoint = null;
|
65 | };
|
66 | |
67 |
|
68 |
|
69 | Move.prototype.reset = function () {
|
70 | this.starting = false;
|
71 | this.startPoint = null;
|
72 | this.isMoving = false;
|
73 | var view = this.context.view;
|
74 | view.backgroundGroup.resetMatrix();
|
75 | view.foregroundGroup.resetMatrix();
|
76 | view.middleGroup.resetMatrix();
|
77 | this.isMoving = false;
|
78 | };
|
79 | return Move;
|
80 | }(__1.Action));
|
81 | exports.default = Move;
|
82 |
|
\ | No newline at end of file |