UNPKG

@visactor/vrender-core

Version:

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

24 lines (22 loc) 1.4 kB
import { Generator } from "../../common/generator"; export class AutoRenderPlugin { constructor() { this.name = "AutoRenderPlugin", this.activeEvent = "onRegister", this._uid = Generator.GenAutoIncrementId(), this.key = this.name + this._uid, this.handleChange = graphic => { graphic.glyphHost && (graphic = graphic.glyphHost), graphic.stage === this.pluginService.stage && null != graphic.stage && graphic.stage.renderNextFrame(); }; } activate(context) { this.pluginService = context; const stage = this.pluginService.stage; stage && (stage.graphicService.hooks.onAttributeUpdate.tap(this.key, this.handleChange), stage.graphicService.hooks.onSetStage.tap(this.key, this.handleChange), stage.graphicService.hooks.onRemove.tap(this.key, this.handleChange)); } deactivate(context) { const filterByName = taps => taps.filter((item => item.name !== this.key)), stage = this.pluginService.stage; stage && (stage.graphicService.hooks.onAttributeUpdate.taps = filterByName(stage.graphicService.hooks.onAttributeUpdate.taps), stage.graphicService.hooks.onSetStage.taps = filterByName(stage.graphicService.hooks.onSetStage.taps), stage.graphicService.hooks.onRemove.taps = filterByName(stage.graphicService.hooks.onRemove.taps)); } } //# sourceMappingURL=auto-render-plugin.js.map