@antv/f6-ui
Version:
UI system for @antv/f6
66 lines (51 loc) • 1.62 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _tslib = require("tslib");
var _base = _interopRequireDefault(require("./base"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var UIImageNode =
/** @class */
function (_super) {
(0, _tslib.__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;
}(_base.default);
var _default = UIImageNode;
exports.default = _default;