@visactor/vrender-components
Version:
components library for dp visualization
45 lines (40 loc) • 2.25 kB
JavaScript
import { PopTip } from "./poptip";
import { merge } from "@visactor/vutils";
import { theme } from "./theme";
function wrapPoptip(target, source) {
return merge(target, theme.poptip, source), target;
}
export class PopTipRenderContribution {
render(graphic, context, x, y, doFill, doStroke, fVisible, sVisible, graphicAttribute, drawContext, fillCb, strokeCb, options) {
var _a, _b;
if (1 === graphic._showPoptip) {
const {visible: visible, visibleCb: visibleCb} = graphic.attribute.poptip || {};
if (!1 === visible || visibleCb && !1 === visibleCb(graphic)) return;
const attribute = {};
merge(attribute, PopTip.defaultAttributes, graphic.attribute.poptip ? graphic.attribute.poptip : {}),
this.poptipComponent ? this.poptipComponent.initAttributes(attribute) : this.poptipComponent = new PopTip(attribute);
let poptip = graphic.attribute.poptip || {};
if ("text" === graphic.type && null == poptip.title && null == poptip.content) {
const out = {};
wrapPoptip(out, poptip), poptip = out, poptip.content = null !== (_a = poptip.content) && void 0 !== _a ? _a : graphic.attribute.text;
}
const matrix = graphic.globalTransMatrix;
this.poptipComponent.setAttributes(Object.assign(Object.assign({
visibleAll: !0,
pickable: !1,
childrenPickable: !1,
poptipAnchor: "bounds"
}, poptip), {
x: matrix.e,
y: matrix.f,
positionBounds: graphic.globalAABBBounds
})), drawContext.stage.tryInitInteractiveLayer();
const interactiveLayer = drawContext.stage.getLayer("_builtin_interactive");
interactiveLayer && interactiveLayer.add(this.poptipComponent);
} else 2 === graphic._showPoptip && (graphic._showPoptip = 0, this.poptipComponent && (this.poptipComponent.setAttributes({
visibleAll: !1
}), null === (_b = this.poptipComponent.parent) || void 0 === _b || _b.removeChild(this.poptipComponent),
this.poptipComponent = null));
}
}
//# sourceMappingURL=contribution.js.map