"use strict"; /** * Animation functions for shape * @author sima.zhang1990@gmail.com */ var Util = require('../util/common'); var 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) { var fillOpacity = Util.isNil(shape.attr('fillOpacity')) ? 1 : shape.attr('fillOpacity'); var strokeOpacity = Util.isNil(shape.attr('strokeOpacity')) ? 1 : shape.attr('strokeOpacity'); shape.attr('fillOpacity', 0); shape.attr('strokeOpacity', 0); var endState = { fillOpacity: fillOpacity, strokeOpacity: strokeOpacity }; Helpers.doAnimation(shape, endState, animateCfg); } module.exports = { // waveIn, // scaleInX, // scaleInY, fadeIn: fadeIn };