shape-action.js 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. "use strict";
  2. exports.__esModule = true;
  3. exports.fadeIn = fadeIn;
  4. var _common = require("../util/common");
  5. var _util = require("./util");
  6. /**
  7. * Animation functions for shape
  8. * @author sima.zhang1990@gmail.com
  9. */
  10. /*
  11. function waveIn(shape, animateCfg, coord) {
  12. const clip = Helpers.getClip(coord);
  13. clip.set('canvas', shape.get('canvas'));
  14. shape.attr('clip', clip);
  15. const onEnd = function() {
  16. shape.attr('clip', null);
  17. clip.remove(true);
  18. };
  19. Helpers.doAnimation(clip, clip.endState, animateCfg, onEnd);
  20. }
  21. function scaleInX(shape, animateCfg) {
  22. const box = shape.getBBox();
  23. const points = shape.get('origin').points;
  24. let x;
  25. const y = (box.minY + box.maxY) / 2;
  26. if (points[0].y - points[1].y > 0) { // 当顶点在零点之下
  27. x = box.maxX;
  28. } else {
  29. x = box.minX;
  30. }
  31. const scaledMatrix = Helpers.getScaledMatrix(shape, [ x, y ], 'x');
  32. Helpers.doAnimation(shape, { matrix: scaledMatrix }, animateCfg);
  33. }
  34. function scaleInY(shape, animateCfg) {
  35. const box = shape.getBBox();
  36. const points = shape.get('origin').points;
  37. const x = (box.minX + box.maxX) / 2;
  38. let y;
  39. if (points[0].y - points[1].y <= 0) { // 当顶点在零点之下
  40. y = box.maxY;
  41. } else {
  42. y = box.minY;
  43. }
  44. const scaledMatrix = Helpers.getScaledMatrix(shape, [ x, y ], 'x');
  45. Helpers.doAnimation(shape, { matrix: scaledMatrix }, animateCfg);
  46. }
  47. */
  48. function fadeIn(shape, animateCfg) {
  49. var fillOpacity = (0, _common.isNil)(shape.attr('fillOpacity')) ? 1 : shape.attr('fillOpacity');
  50. var strokeOpacity = (0, _common.isNil)(shape.attr('strokeOpacity')) ? 1 : shape.attr('strokeOpacity');
  51. shape.attr('fillOpacity', 0);
  52. shape.attr('strokeOpacity', 0);
  53. var endState = {
  54. fillOpacity: fillOpacity,
  55. strokeOpacity: strokeOpacity
  56. };
  57. (0, _util.doAnimation)(shape, endState, animateCfg);
  58. }