@antv/f6-ui
Version:
UI system for @antv/f6
55 lines (44 loc) • 1.35 kB
JavaScript
import { __extends } from "tslib";
import UINode from './base';
var UIImageNode =
/** @class */
function (_super) {
__extends(UIImageNode, _super);
function UIImageNode() {
return _super !== null && _super.apply(this, arguments) || this;
}
UIImageNode.prototype.draw = function (parentGNode) {
var attrs = {
x: this.styleNode.layout.left,
y: this.styleNode.layout.top,
img: this.styleNode.dom.attrs.src,
width: this.styleNode.layout.width || 0,
height: this.styleNode.layout.height || 0
};
var isCapture = this.styleNode.style.pointerEvents === 'none' ? false : true;
if (!this.gNode) {
this.gNode = parentGNode.addShape('image', {
type: 'image',
attrs: attrs,
capture: isCapture
});
}
var shape = this.gNode;
shape.resetMatrix();
shape.set('capture', isCapture);
shape.attr(attrs); // zIndex
typeof this.styleNode.style.zIndex === 'number' && shape.setZIndex(this.styleNode.style.zIndex);
switch (this.styleNode.style.textAlign) {
case 'center':
shape.translate(this.styleNode.layout.width / 2);
break;
case 'right':
shape.translate(this.styleNode.layout.width);
break;
default:
break;
}
};
return UIImageNode;
}(UINode);
export default UIImageNode;