UNPKG

@visactor/vrender-components

Version:

components library for dp visualization

79 lines (70 loc) 2.87 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: !0 }), exports.PopTipForClipedTextPlugin = exports.PopTipPlugin = exports.PopTipPluginBase = void 0; const vrender_core_1 = require("@visactor/vrender-core"); class PopTipPluginBase { constructor() { this.activeEvent = "onRegister", this._uid = vrender_core_1.Generator.GenAutoIncrementId(), this.poptip = e => { const graphic = e.target; this.needHide(graphic) ? this.unpoptip(e) : graphic !== this.activeGraphic && (this.needShow(graphic) && (graphic.setAttributes({}), graphic._showPoptip = 1), this.activeGraphic && (this.activeGraphic.setAttributes({}), this.activeGraphic._showPoptip = 2), this.setActiveGraphic(graphic, !0)); }, this.unpoptip = e => { this.activeGraphic && (this.activeGraphic.setAttributes({}), this.activeGraphic._showPoptip = 2, this.setActiveGraphic(null, !0)); }; } activate(context) { this.pluginService = context; const {stage: stage} = this.pluginService; stage.addEventListener("pointerover", this.poptip); } needHide(graphic) { return graphic.isContainer || !graphic.attribute; } needShow(graphic) { return !!graphic.attribute.poptip; } setActiveGraphic(graphic, rerender) { this.activeGraphic = graphic, this.pluginService.stage.renderNextFrame(); } deactivate(context) { const {stage: stage} = this.pluginService; stage.removeEventListener("pointerover", this.poptip); } } exports.PopTipPluginBase = PopTipPluginBase; class PopTipPlugin extends PopTipPluginBase { constructor() { super(...arguments), this.name = "poptip", this.key = this.name + this._uid; } } exports.PopTipPlugin = PopTipPlugin; class PopTipForClipedTextPlugin extends PopTipPluginBase { constructor() { super(...arguments), this.name = "poptipForText", this.key = this.name + this._uid, this.pointerlave = e => { const {stage: stage} = this.pluginService; e.target === stage && this.unpoptip(e); }; } activate(context) { super.activate(context); const {stage: stage} = this.pluginService; stage.addEventListener("pointerleave", this.pointerlave); } needHide(graphic) { return "text" !== graphic.type || !graphic.cliped || graphic.isContainer || !graphic.attribute || graphic.attribute.disableAutoClipedPoptip; } needShow(graphic) { return !0; } deactivate(context) { const {stage: stage} = this.pluginService; super.deactivate(context), stage.removeEventListener("pointerleave", this.pointerlave); } } exports.PopTipForClipedTextPlugin = PopTipForClipedTextPlugin; //# sourceMappingURL=poptip-plugin.js.map