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