light-chart
Version:
Charts for mobile visualization.
69 lines (61 loc) • 1.8 kB
JavaScript
/**
* Animation functions for shape
* @author sima.zhang1990@gmail.com
*/
const Util = require('../util/common');
const Helpers = require('./util');
/*
function waveIn(shape, animateCfg, coord) {
const clip = Helpers.getClip(coord);
clip.set('canvas', shape.get('canvas'));
shape.attr('clip', clip);
const onEnd = function() {
shape.attr('clip', null);
clip.remove(true);
};
Helpers.doAnimation(clip, clip.endState, animateCfg, onEnd);
}
function scaleInX(shape, animateCfg) {
const box = shape.getBBox();
const points = shape.get('origin').points;
let x;
const y = (box.minY + box.maxY) / 2;
if (points[0].y - points[1].y > 0) { // 当顶点在零点之下
x = box.maxX;
} else {
x = box.minX;
}
const scaledMatrix = Helpers.getScaledMatrix(shape, [ x, y ], 'x');
Helpers.doAnimation(shape, { matrix: scaledMatrix }, animateCfg);
}
function scaleInY(shape, animateCfg) {
const box = shape.getBBox();
const points = shape.get('origin').points;
const x = (box.minX + box.maxX) / 2;
let y;
if (points[0].y - points[1].y <= 0) { // 当顶点在零点之下
y = box.maxY;
} else {
y = box.minY;
}
const scaledMatrix = Helpers.getScaledMatrix(shape, [ x, y ], 'x');
Helpers.doAnimation(shape, { matrix: scaledMatrix }, animateCfg);
}
*/
function fadeIn(shape, animateCfg) {
const fillOpacity = Util.isNil(shape.attr('fillOpacity')) ? 1 : shape.attr('fillOpacity');
const strokeOpacity = Util.isNil(shape.attr('strokeOpacity')) ? 1 : shape.attr('strokeOpacity');
shape.attr('fillOpacity', 0);
shape.attr('strokeOpacity', 0);
const endState = {
fillOpacity,
strokeOpacity
};
Helpers.doAnimation(shape, endState, animateCfg);
}
module.exports = {
// waveIn,
// scaleInX,
// scaleInY,
fadeIn
};