UNPKG

1.26 kBJavaScriptView Raw
1import { jsx } from '@antv/f-engine';
2import { deepMix } from '@antv/util';
3import Lottie from '@antv/f-lottie';
4var defaultProps = {
5 offsetX: 0,
6 offsetY: 0,
7 points: [],
8 data: '',
9 animation: null,
10 options: {
11 loop: true,
12 autoplay: true
13 }
14};
15export default (function (props, context) {
16 var cfg = deepMix({}, defaultProps, props);
17 var points = cfg.points,
18 style = cfg.style,
19 offsetX = cfg.offsetX,
20 offsetY = cfg.offsetY,
21 lottieJson = cfg.lottieJson,
22 animation = cfg.animation,
23 options = cfg.options;
24 var _a = points[0] || {},
25 x = _a.x,
26 y = _a.y;
27 if (isNaN(x) || isNaN(y)) return null;
28 var _b = style.height,
29 height = _b === void 0 ? 0 : _b,
30 _c = style.width,
31 width = _c === void 0 ? 0 : _c;
32 var offsetXNum = context.px2hd(offsetX);
33 var offsetYNum = context.px2hd(offsetY);
34 var posX = x + (offsetXNum || 0) - width / 2;
35 var posY = y + (offsetYNum || 0) - height / 2;
36 return jsx(Lottie, {
37 data: lottieJson,
38 options: options,
39 style: {
40 x: posX,
41 y: posY,
42 width: width,
43 height: height
44 },
45 animation: deepMix({
46 update: {
47 easing: 'linear',
48 duration: 450,
49 property: ['x', 'y']
50 }
51 }, animation)
52 });
53});
\No newline at end of file