@antv/f2
Version:
Charts for mobile visualization.
56 lines (55 loc) • 1.7 kB
JavaScript
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _tslib = require("tslib");
var _fEngine = require("@antv/f-engine");
var _util = require("@antv/util");
var defaultProps = {
offsetX: 0,
offsetY: 0,
points: [],
src: ''
};
var _default = exports.default = function _default(props, context) {
var cfg = (0, _util.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 _a = points[0] || {},
x = _a.x,
y = _a.y;
if (isNaN(x) || isNaN(y)) return null;
var _b = (0, _tslib.__assign)((0, _tslib.__assign)({}, attrs), style),
_c = _b.height,
height = _c === void 0 ? 0 : _c,
_d = _b.width,
width = _d === void 0 ? 0 : _d;
var heightNum = (0, _util.isNumber)(height) ? context.px2hd(height + 'px') : context.px2hd(height);
var widthNum = (0, _util.isNumber)(width) ? context.px2hd(width + 'px') : context.px2hd(width);
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 (0, _fEngine.jsx)("group", null, (0, _fEngine.jsx)("image", {
style: (0, _tslib.__assign)((0, _tslib.__assign)((0, _tslib.__assign)({}, attrs), style), {
height: heightNum,
width: widthNum,
x: posX,
y: posY,
src: src
}),
animation: (0, _util.deepMix)({
update: {
easing: 'linear',
duration: 450,
property: ['x', 'y']
}
}, animation)
}));
};
;