UNPKG

2.01 kBJavaScriptView Raw
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3exports.scaleInY = exports.scaleInX = void 0;
4var matrix_util_1 = require("@antv/matrix-util");
5/**
6 * @ignore
7 * 沿着 x 方向放大的动画
8 * @param shape
9 * @param animateCfg
10 * @param shapeModel
11 */
12function scaleInX(shape, animateCfg, cfg) {
13 var box = shape.getBBox();
14 var mappingData = shape.get('origin').mappingData;
15 var points = mappingData.points;
16 // x 数值如果为负值,那么应该从右往左生长
17 var x = points[0].y - points[1].y > 0 ? box.maxX : box.minX;
18 var y = (box.minY + box.maxY) / 2;
19 shape.applyToMatrix([x, y, 1]);
20 var matrix = matrix_util_1.ext.transform(shape.getMatrix(), [
21 ['t', -x, -y],
22 ['s', 0.01, 1],
23 ['t', x, y],
24 ]);
25 shape.setMatrix(matrix);
26 shape.animate({
27 matrix: matrix_util_1.ext.transform(shape.getMatrix(), [
28 ['t', -x, -y],
29 ['s', 100, 1],
30 ['t', x, y],
31 ]),
32 }, animateCfg);
33}
34exports.scaleInX = scaleInX;
35/**
36 * @ignore
37 * 沿着 y 方向放大的动画
38 * @param shape
39 * @param animateCfg
40 * @param shapeModel
41 */
42function scaleInY(shape, animateCfg, cfg) {
43 var box = shape.getBBox();
44 var mappingData = shape.get('origin').mappingData;
45 var x = (box.minX + box.maxX) / 2;
46 var points = mappingData.points;
47 // 数值如果为负值,那么应该从上往下生长,通过 shape 的关键点进行判断
48 var y = points[0].y - points[1].y <= 0 ? box.maxY : box.minY;
49 shape.applyToMatrix([x, y, 1]);
50 var matrix = matrix_util_1.ext.transform(shape.getMatrix(), [
51 ['t', -x, -y],
52 ['s', 1, 0.01],
53 ['t', x, y],
54 ]);
55 shape.setMatrix(matrix);
56 shape.animate({
57 matrix: matrix_util_1.ext.transform(shape.getMatrix(), [
58 ['t', -x, -y],
59 ['s', 1, 100],
60 ['t', x, y],
61 ]),
62 }, animateCfg);
63}
64exports.scaleInY = scaleInY;
65//# sourceMappingURL=scale-in.js.map
\No newline at end of file