UNPKG

@visactor/vrender-core

Version:

```typescript import { xxx } from '@visactor/vrender-core'; ```

43 lines (38 loc) 2.92 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: !0 }), exports.DirtyBoundsPlugin = void 0; const vutils_1 = require("@visactor/vutils"), generator_1 = require("../../common/generator"), globalBounds = new vutils_1.AABBBounds; class DirtyBoundsPlugin { constructor() { this.name = "DirtyBoundsPlugin", this.activeEvent = "onRegister", this._uid = generator_1.Generator.GenAutoIncrementId(), this.key = this.name + this._uid; } activate(context) { this.pluginService = context, context.stage.hooks.afterRender.tap(this.key, (stage => { stage && stage === this.pluginService.stage && stage.dirtyBounds.clear(); })); const stage = this.pluginService.stage; stage && (stage.graphicService.hooks.beforeUpdateAABBBounds.tap(this.key, ((graphic, stage, willUpdate, bounds) => { graphic.glyphHost && (graphic = graphic.glyphHost), stage && stage === this.pluginService.stage && stage.renderCount && (graphic.isContainer && !graphic.shouldSelfChangeUpdateAABBBounds() || willUpdate && (globalBounds.setValue(bounds.x1, bounds.y1, bounds.x2, bounds.y2), stage.dirty(globalBounds, graphic.parent && graphic.parent.globalTransMatrix))); })), stage.graphicService.hooks.afterUpdateAABBBounds.tap(this.key, ((graphic, stage, bounds, params, selfChange) => { stage && stage === this.pluginService.stage && stage.renderCount && (graphic.isContainer && !selfChange || stage.dirty(params.globalAABBBounds)); })), stage.graphicService.hooks.clearAABBBounds.tap(this.key, ((graphic, stage, bounds) => { stage && stage === this.pluginService.stage && stage.renderCount && stage && stage.dirty(bounds); })), stage.graphicService.hooks.onRemove.tap(this.key, (graphic => { const stage = graphic.stage; stage && stage === this.pluginService.stage && stage.renderCount && stage && stage.dirty(graphic.globalAABBBounds); }))); } deactivate(context) { const stage = this.pluginService.stage; stage && (stage.graphicService.hooks.beforeUpdateAABBBounds.taps = stage.graphicService.hooks.beforeUpdateAABBBounds.taps.filter((item => item.name !== this.key)), stage.graphicService.hooks.afterUpdateAABBBounds.taps = stage.graphicService.hooks.afterUpdateAABBBounds.taps.filter((item => item.name !== this.key)), stage.graphicService.hooks.clearAABBBounds.taps = stage.graphicService.hooks.clearAABBBounds.taps.filter((item => item.name !== this.key)), stage.hooks.afterRender.taps = stage.hooks.afterRender.taps.filter((item => item.name !== this.key)), stage.graphicService.hooks.onRemove.taps = stage.graphicService.hooks.onRemove.taps.filter((item => item.name !== this.key))); } } exports.DirtyBoundsPlugin = DirtyBoundsPlugin; //# sourceMappingURL=dirty-bounds-plugin.js.map