NuclearDispersionSystem/ant-design-vue-jeecg/node_modules/@antv/g2/esm/animate/animation/zoom.js

66 lines
2.0 KiB
Java
Raw Normal View History

2023-09-14 14:47:11 +08:00
import { __assign } from "tslib";
import { ext } from '@antv/matrix-util';
import { each } from '@antv/util';
function doShapeZoom(shape, animateCfg, type) {
if (shape.isGroup()) {
each(shape.getChildren(), function (child) {
doShapeZoom(child, animateCfg, type);
});
}
else {
var bbox = shape.getBBox();
var x = (bbox.minX + bbox.maxX) / 2;
var y = (bbox.minY + bbox.maxY) / 2;
shape.applyToMatrix([x, y, 1]);
if (type === 'zoomIn') {
// 放大
var matrix = ext.transform(shape.getMatrix(), [
['t', -x, -y],
['s', 0.01, 0.01],
['t', x, y],
]);
shape.setMatrix(matrix);
shape.animate({
matrix: ext.transform(shape.getMatrix(), [
['t', -x, -y],
['s', 100, 100],
['t', x, y],
]),
}, animateCfg);
}
else {
shape.animate({
matrix: ext.transform(shape.getMatrix(), [
['t', -x, -y],
['s', 0.01, 0.01],
['t', x, y],
]),
}, __assign(__assign({}, animateCfg), { callback: function () {
shape.remove(true);
} }));
}
}
}
/**
* @ignore
* 单个 shape 动画
* shape 以自身中心点逐渐放大的进入动画
* @param shape 参与动画的图形元素
* @param animateCfg 动画配置
* @param cfg 额外信息
*/
export function zoomIn(shape, animateCfg, cfg) {
doShapeZoom(shape, animateCfg, 'zoomIn');
}
/**
* @ignore
* 单个 shape 动画
* 消失动画shape 以自身为中心点的逐渐缩小
* @param shape 参与动画的图形元素
* @param animateCfg 动画配置
* @param cfg 额外信息
*/
export function zoomOut(shape, animateCfg, cfg) {
doShapeZoom(shape, animateCfg, 'zoomOut');
}
//# sourceMappingURL=zoom.js.map