@antv/f2
Version:
Charts for mobile visualization.
55 lines • 1.49 kB
JavaScript
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
import { jsx } from '../../../jsx';
import { deepMix } from '@antv/util';
var defaultProps = {
offsetX: 0,
offsetY: 0,
points: [],
src: ''
};
var baseAttrs = {
height: '20px',
width: '20px'
};
export default (function (props, context) {
var cfg = deepMix({}, defaultProps, props);
var points = cfg.points,
style = cfg.style,
attrs = cfg.attrs,
offsetX = cfg.offsetX,
offsetY = cfg.offsetY,
src = cfg.src,
animation = cfg.animation;
var _ref = points[0] || {},
x = _ref.x,
y = _ref.y;
var _attrs$height = attrs.height,
height = _attrs$height === void 0 ? 0 : _attrs$height,
_attrs$width = attrs.width,
width = _attrs$width === void 0 ? 0 : _attrs$width;
var heightNum = context.px2hd(height + 'px');
var widthNum = context.px2hd(width + 'px');
var offsetXNum = context.px2hd(offsetX);
var offsetYNum = context.px2hd(offsetY);
var posX = x + (offsetXNum || 0) - widthNum / 2;
var posY = y + (offsetYNum || 0) - heightNum / 2;
return jsx("group", {
style: style
}, jsx("image", {
attrs: _objectSpread(_objectSpread(_objectSpread({}, baseAttrs), attrs), {}, {
height: heightNum,
width: widthNum,
x: posX,
y: posY,
src: src
}),
cacheImage: true,
animation: deepMix({
update: {
easing: 'linear',
duration: 450,
property: ['x', 'y']
}
}, animation)
}));
});