Skip to content

Commit

Permalink
feat: defer display until layout provides position (#509)
Browse files Browse the repository at this point in the history
  • Loading branch information
steveblue authored Jun 30, 2023
1 parent 7fe3b4c commit 0dfd112
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
(click)="onClick(node)"
>
<ng-container
*ngIf="clusterTemplate"
*ngIf="clusterTemplate && !node.hidden"
[ngTemplateOutlet]="clusterTemplate"
[ngTemplateOutletContext]="{ $implicit: node }"
></ng-container>
Expand Down Expand Up @@ -75,7 +75,7 @@
(mousedown)="onNodeMouseDown($event, node)"
>
<ng-container
*ngIf="nodeTemplate"
*ngIf="nodeTemplate && !node.hidden"
[ngTemplateOutlet]="nodeTemplate"
[ngTemplateOutletContext]="{ $implicit: node }"
></ng-container>
Expand Down Expand Up @@ -115,7 +115,7 @@
(mousedown)="onNodeMouseDown($event, node)"
>
<ng-container
*ngIf="nodeTemplate"
*ngIf="nodeTemplate && !node.hidden"
[ngTemplateOutlet]="nodeTemplate"
[ngTemplateOutletContext]="{ $implicit: node }"
></ng-container>
Expand Down
7 changes: 7 additions & 0 deletions projects/swimlane/ngx-graph/src/lib/graph/graph.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ export class GraphComponent implements OnInit, OnChanges, OnDestroy, AfterViewIn
@Input() scheme: any = 'cool';
@Input() customColors: any;
@Input() animations: boolean = true;
@Input() deferDisplayUntilPosition: boolean = false;
@Output() select = new EventEmitter();

@Output() activate: EventEmitter<any> = new EventEmitter();
Expand Down Expand Up @@ -368,6 +369,9 @@ export class GraphComponent implements OnInit, OnChanges, OnDestroy, AfterViewIn
x: 0,
y: 0
};
if (this.deferDisplayUntilPosition) {
n.hidden = true;
}
}

n.data = n.data ? n.data : {};
Expand Down Expand Up @@ -435,6 +439,9 @@ export class GraphComponent implements OnInit, OnChanges, OnDestroy, AfterViewIn
n.data = {};
}
n.data.color = this.colors.getColor(this.groupResultsBy(n));
if (this.deferDisplayUntilPosition) {
n.hidden = false;
}
oldNodes.add(n.id);
});

Expand Down
1 change: 1 addition & 0 deletions projects/swimlane/ngx-graph/src/lib/models/node.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export interface Node {
meta?: any;
layoutOptions?: any;
parentId?: string;
hidden?: boolean;
}

export interface ClusterNode extends Node {
Expand Down

0 comments on commit 0dfd112

Please sign in to comment.