From 235fb43f17cb0e8e8548e9d4a655d0a8b7dc6717 Mon Sep 17 00:00:00 2001 From: Yavor Stoychev Date: Fri, 24 May 2019 20:25:45 +0300 Subject: [PATCH 1/2] Structure Directive - Bug This is a setter that will be triggered when the user uses structure directives and it's going to update the elements. --- lib/components/core-shape.component.ts | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/lib/components/core-shape.component.ts b/lib/components/core-shape.component.ts index b956724..64eb114 100644 --- a/lib/components/core-shape.component.ts +++ b/lib/components/core-shape.component.ts @@ -30,8 +30,15 @@ declare const Konva: any; }) export class CoreShapeComponent implements KonvaComponent, AfterContentInit, OnDestroy, OnInit { - @ContentChildren(CoreShapeComponent) - shapes = new QueryList(); + public shapes = new QueryList(); + @ContentChildren(CoreShape) set content(list: QueryList) { + this.shapes = list; + + this.shapes.forEach((item: CoreShape) => { + this._stage.add(item.getStage()); + updatePicture(this._stage); + }); + } @Input() config: Observable; @Output() click: EventEmitter = new EventEmitter(); @Output() dblclick: EventEmitter = new EventEmitter(); From fa5d85d1b7e42c7c020de7a6000230c35c6e53a1 Mon Sep 17 00:00:00 2001 From: Yavor Stoychev Date: Fri, 24 May 2019 20:28:30 +0300 Subject: [PATCH 2/2] Remove the logic from the ngAfterContentInit --- lib/components/core-shape.component.ts | 7 ------- 1 file changed, 7 deletions(-) diff --git a/lib/components/core-shape.component.ts b/lib/components/core-shape.component.ts index 64eb114..4b3912d 100644 --- a/lib/components/core-shape.component.ts +++ b/lib/components/core-shape.component.ts @@ -112,13 +112,6 @@ export class CoreShapeComponent } ngAfterContentInit() { - this.shapes.forEach((item: CoreShapeComponent) => { - if (this !== item) { - item.added = true; - this._stage.add(item.getStage()); - updatePicture(this._stage); - } - }); } ngOnDestroy() {