UNPKG

@antv/f2

Version:

Charts for mobile visualization.

53 lines 1.26 kB
import { jsx } from '@antv/f-engine'; import { deepMix } from '@antv/util'; import Lottie from '@antv/f-lottie'; var defaultProps = { offsetX: 0, offsetY: 0, points: [], data: '', animation: null, options: { loop: true, autoplay: true } }; export default (function (props, context) { var cfg = deepMix({}, defaultProps, props); var points = cfg.points, style = cfg.style, offsetX = cfg.offsetX, offsetY = cfg.offsetY, lottieJson = cfg.lottieJson, animation = cfg.animation, options = cfg.options; var _a = points[0] || {}, x = _a.x, y = _a.y; if (isNaN(x) || isNaN(y)) return null; var _b = style.height, height = _b === void 0 ? 0 : _b, _c = style.width, width = _c === void 0 ? 0 : _c; var offsetXNum = context.px2hd(offsetX); var offsetYNum = context.px2hd(offsetY); var posX = x + (offsetXNum || 0) - width / 2; var posY = y + (offsetYNum || 0) - height / 2; return jsx(Lottie, { data: lottieJson, options: options, style: { x: posX, y: posY, width: width, height: height }, animation: deepMix({ update: { easing: 'linear', duration: 450, property: ['x', 'y'] } }, animation) }); });