| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081 |
- "use strict";
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.WaveIn = void 0;
- const d3_shape_1 = require("d3-shape");
- const g_1 = require("@antv/g");
- const utils_1 = require("../shape/utils");
- const coordinate_1 = require("../utils/coordinate");
- const utils_2 = require("./utils");
- const scaleInX_1 = require("./scaleInX");
- /**
- * Transform mark from transparent to solid.
- */
- const WaveIn = (options) => {
- const ZERO = 0.0001;
- // @see https://g-next.antv.vision/zh/docs/api/css/css-properties-values-api#%E8%87%AA%E5%AE%9A%E4%B9%89%E5%B1%9E%E6%80%A7
- g_1.CSS.registerProperty({
- name: 'waveInArcAngle',
- inherits: false,
- initialValue: '',
- interpolable: true,
- syntax: g_1.PropertySyntax.NUMBER,
- });
- return (from, to, value, coordinate, defaults) => {
- const [shape] = from;
- if (!(0, coordinate_1.isPolar)(coordinate)) {
- return (0, scaleInX_1.ScaleInX)(options)(from, to, value, coordinate, defaults);
- }
- const center = coordinate.getCenter();
- const { __data__, style } = shape;
- const { radius = 0, inset = 0, fillOpacity = 1, strokeOpacity = 1, opacity = 1, } = style;
- const { points, y, y1 } = __data__;
- const path = (0, d3_shape_1.arc)()
- .cornerRadius(radius)
- .padAngle((inset * Math.PI) / 180);
- const arcObject = (0, utils_1.getArcObject)(coordinate, points, [y, y1]);
- const { startAngle, endAngle } = arcObject;
- const pathForConversion = new g_1.Path({});
- const createArcPath = (arcParams) => {
- pathForConversion.attr({
- d: path(arcParams),
- transform: `translate(${center[0]}, ${center[1]})`,
- });
- const convertedPathDefinition = (0, g_1.convertToPath)(pathForConversion);
- pathForConversion.style.transform = '';
- return convertedPathDefinition;
- };
- const keyframes = [
- // Use custom interpolable CSS property.
- {
- waveInArcAngle: startAngle + ZERO,
- fillOpacity: 0,
- strokeOpacity: 0,
- opacity: 0,
- },
- {
- waveInArcAngle: startAngle + ZERO,
- fillOpacity,
- strokeOpacity,
- opacity,
- offset: 0.01,
- },
- {
- waveInArcAngle: endAngle,
- fillOpacity,
- strokeOpacity,
- opacity,
- },
- ];
- const animation = shape.animate(keyframes, (0, utils_2.effectTiming)(defaults, value, options));
- animation.onframe = function () {
- shape.style.path = createArcPath(Object.assign(Object.assign({}, arcObject), { endAngle: Number(shape.style.waveInArcAngle) }));
- };
- animation.onfinish = function () {
- shape.style.path = createArcPath(Object.assign(Object.assign({}, arcObject), { endAngle: endAngle }));
- };
- return animation;
- };
- };
- exports.WaveIn = WaveIn;
- exports.WaveIn.props = {};
- //# sourceMappingURL=waveIn.js.map
|