From 40986f2e5d280ea044f26ba288207c5ff0716c08 Mon Sep 17 00:00:00 2001 From: Arnaud Fiorini Date: Thu, 4 Mar 2021 19:57:40 -0500 Subject: [PATCH] Destroy arrows when updating them Signed-off-by: Arnaud Fiorini --- timeline-chart/src/components/time-graph-arrow.ts | 5 +++++ timeline-chart/src/components/time-graph-component.ts | 4 ++++ timeline-chart/src/layer/time-graph-chart-arrows.ts | 3 +++ 3 files changed, 12 insertions(+) diff --git a/timeline-chart/src/components/time-graph-arrow.ts b/timeline-chart/src/components/time-graph-arrow.ts index 8f5e50f..a037b71 100644 --- a/timeline-chart/src/components/time-graph-arrow.ts +++ b/timeline-chart/src/components/time-graph-arrow.ts @@ -17,6 +17,11 @@ export class TimeGraphArrowComponent extends TimeGraphComponent { this.head = new PIXI.Graphics(); } + destroy() { + this.head.destroy(); + super.destroy(); + } + render(): void { const { start, end } = this._options as TimeGraphArrowCoordinates; this._displayObject.lineStyle(1, 0x000000); diff --git a/timeline-chart/src/components/time-graph-component.ts b/timeline-chart/src/components/time-graph-component.ts index dcf6340..7109743 100644 --- a/timeline-chart/src/components/time-graph-component.ts +++ b/timeline-chart/src/components/time-graph-component.ts @@ -59,6 +59,10 @@ export abstract class TimeGraphComponent { this._displayObject.clear(); } + destroy() { + this._displayObject.destroy(); + } + update(opts?: TimeGraphComponentOptions) { if (opts) { this._options = opts; diff --git a/timeline-chart/src/layer/time-graph-chart-arrows.ts b/timeline-chart/src/layer/time-graph-chart-arrows.ts index c534255..fc75dc5 100644 --- a/timeline-chart/src/layer/time-graph-chart-arrows.ts +++ b/timeline-chart/src/layer/time-graph-chart-arrows.ts @@ -39,6 +39,9 @@ export class TimeGraphChartArrows extends TimeGraphChartLayer { if (!this.stateController) { throw ('Add this TimeGraphChartArrows to a container before adding arrows.'); } + if (this.arrows) { + this.arrows.forEach(rowEl => rowEl.destroy()); + } this.arrows = new Map(); arrows.forEach(arrow => { this.addArrow(arrow);