suoqiu-f2
Version:
Charts for mobile visualization.
125 lines (123 loc) • 3.65 kB
JavaScript
;
exports.__esModule = true;
exports.groupScaleInX = groupScaleInX;
exports.groupScaleInXY = groupScaleInXY;
exports.groupScaleInY = groupScaleInY;
exports.groupWaveIn = groupWaveIn;
exports.shapesScaleInX = shapesScaleInX;
exports.shapesScaleInXY = shapesScaleInXY;
exports.shapesScaleInY = shapesScaleInY;
var _util = require("./util");
var _helper = require("../util/helper");
var _index = require("../graphic/index");
/**
* Group animate functions
* @author sima.zhang1990@gmail.com
*/
function _groupScaleIn(container, animateCfg, coord, zeroY, type) {
var _getCoordInfo = (0, _util.getCoordInfo)(coord),
start = _getCoordInfo.start,
end = _getCoordInfo.end,
width = _getCoordInfo.width,
height = _getCoordInfo.height;
var x;
var y;
var clip = new _index.Shape.Rect({
attrs: {
x: start.x,
y: end.y,
width: width,
height: height
}
});
if (type === 'y') {
x = start.x + width / 2;
y = zeroY.y < start.y ? zeroY.y : start.y;
} else if (type === 'x') {
x = zeroY.x > start.x ? zeroY.x : start.x;
y = start.y + height / 2;
} else if (type === 'xy') {
if (coord.isPolar) {
x = coord.center.x;
y = coord.center.y;
} else {
x = (start.x + end.x) / 2;
y = (start.y + end.y) / 2;
}
}
var endMatrix = (0, _util.getScaledMatrix)(clip, [x, y], type);
clip.isClip = true;
clip.endState = {
matrix: endMatrix
};
clip.set('canvas', container.get('canvas'));
container.attr('clip', clip);
var onEnd = function onEnd() {
container.attr('clip', null);
clip.remove(true);
};
(0, _util.doAnimation)(clip, clip.endState, animateCfg, onEnd);
}
function _shapeScale(container, animateCfg, type) {
var shapes = container.get('children');
var x;
var y;
var endMatrix;
for (var i = 0, len = shapes.length; i < len; i++) {
var shape = shapes[i];
var box = shape.getBBox();
x = (box.minX + box.maxX) / 2;
y = (box.minY + box.maxY) / 2;
endMatrix = (0, _util.getScaledMatrix)(shape, [x, y], type);
(0, _util.doAnimation)(shape, {
matrix: endMatrix
}, animateCfg);
}
}
function groupScaleInX(container, animateCfg, coord, zeroY) {
_groupScaleIn(container, animateCfg, coord, zeroY, 'x');
}
function groupScaleInY(container, animateCfg, coord, zeroY) {
_groupScaleIn(container, animateCfg, coord, zeroY, 'y');
}
function groupScaleInXY(container, animateCfg, coord, zeroY) {
_groupScaleIn(container, animateCfg, coord, zeroY, 'xy');
}
function shapesScaleInX(container, animateCfg) {
_shapeScale(container, animateCfg, 'x');
}
function shapesScaleInY(container, animateCfg) {
_shapeScale(container, animateCfg, 'y');
}
function shapesScaleInXY(container, animateCfg) {
_shapeScale(container, animateCfg, 'xy');
}
function groupWaveIn(container, animateCfg, coord) {
var clip = (0, _helper.getClip)(coord);
clip.set('canvas', container.get('canvas'));
container.attr('clip', clip);
var onEnd = function onEnd() {
container.attr('clip', null);
clip.remove(true);
};
var endState = {};
if (coord.isPolar) {
var startAngle = coord.startAngle,
endAngle = coord.endAngle;
endState.endAngle = endAngle;
clip.attr('endAngle', startAngle);
} else {
var start = coord.start,
end = coord.end;
var width = Math.abs(start.x - end.x);
var height = Math.abs(start.y - end.y);
if (coord.isTransposed) {
clip.attr('height', 0);
endState.height = height;
} else {
clip.attr('width', 0);
endState.width = width;
}
}
(0, _util.doAnimation)(clip, endState, animateCfg, onEnd);
}