-
Notifications
You must be signed in to change notification settings - Fork 112
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Virtual scrolling * Styles update * Virtual scrolling v2 * Virtual scrolling v3 * Virtual scrolling v4 * Virtual scrolling v5 * Virtual scrolling v6 * Virtual scrolling v7
- Loading branch information
1 parent
6357e9b
commit f9da4fa
Showing
13 changed files
with
687 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
82 changes: 60 additions & 22 deletions
82
projects/swimlane/ngx-ui/src/lib/components/tree/tree.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,63 @@ | ||
<div class="ngx-tree" [class.one-leaf]="hasOneLeaf"> | ||
<ul class="vertical-list"> | ||
<ngx-tree-node | ||
*ngFor="let node of nodes" | ||
[node]="node" | ||
[disabled]="node.disabled" | ||
[expandable]="node.expandable" | ||
[expanded]="node.expanded" | ||
[selectable]="node.selectable" | ||
[icons]="icons" | ||
[label]="node.label" | ||
[model]="node.model" | ||
[children]="node.children" | ||
[template]="template" | ||
(expand)="expand.emit($event)" | ||
(collapse)="collapse.emit($event)" | ||
(activate)="activate.emit($event)" | ||
(deactivate)="deactivate.emit($event)" | ||
(selectNode)="selectNode.emit($event)" | ||
<div class="ngx-tree" [class.one-leaf]="!virtualScrolling && hasOneLeaf"> | ||
<ul class="vertical-list"> | ||
<cdk-virtual-scroll-viewport | ||
*ngIf="treeStructure && virtualScrolling" | ||
[itemSize]="nodeHeight" | ||
[minBufferPx]="nodeHeight * filteredTree.length > maxVirtualScrollHeight ? maxVirtualScrollHeight * 2 : (nodeHeight * filteredTree.length) * 2" | ||
[maxBufferPx]="nodeHeight * filteredTree.length > maxVirtualScrollHeight ? maxVirtualScrollHeight * 4 : (nodeHeight * filteredTree.length) * 4" | ||
class="virtual-container" | ||
[style.height]="nodeHeight * filteredTree.length > maxVirtualScrollHeight ? maxVirtualScrollHeight + 'px' : (nodeHeight * filteredTree.length) + 'px'" | ||
> | ||
</ngx-tree-node> | ||
<ng-content *ngIf="!nodes"></ng-content> | ||
<ng-container *cdkVirtualFor="let node of filteredTree; let i = index; let c = count; trackBy: trackBy;"> | ||
<div class="node-container" [style.height]="nodeHeight + 'px'" > | ||
<div | ||
[class]="i === c - 1 && c > 1 ? 'depth-indicator_filled' : 'depth-indicator'" | ||
[style.width]="i + 1 !== c && node.depth - filteredTree[i + 1].depth > 1 ? (node.depth - (node.depth - filteredTree[i + 1].depth)) * depthPadding + 'px' : ((node.depth - 1) * depthPadding) + 'px'" | ||
[style.height]="nodeHeight + 'px'" | ||
></div> | ||
<div | ||
*ngIf="i + 1 !== c && node.depth - filteredTree[i + 1].depth > 1" | ||
class="depth-indicator_filled" | ||
[style.width]="(node.depth - filteredTree[i + 1].depth - 1) * depthPadding + 'px'" | ||
></div> | ||
<div | ||
[class.empty]="empty | memoize: node:filteredTree" | ||
[class.filled]="filled | memoize: node:filteredTree" | ||
[class.filled-single]="filled | memoize: node:filteredTree:true" | ||
[class.dots]="dots | memoize: node:filteredTree" | ||
> | ||
<ng-container [ngTemplateOutlet]="ngxTreeNode" [ngTemplateOutletContext]="{ node }"></ng-container> | ||
</div> | ||
</div> | ||
</ng-container> | ||
</cdk-virtual-scroll-viewport> | ||
<ng-container *ngIf="nodes?.length && !nodeElms?.length && !virtualScrolling"> | ||
<ng-container *ngFor="let node of nodes"> | ||
<ng-container [ngTemplateOutlet]="ngxTreeNode" [ngTemplateOutletContext]="{ node }"></ng-container> | ||
</ng-container> | ||
</ng-container> | ||
<ng-content *ngIf="!nodes?.length && nodeElms?.length && !virtualScrolling"></ng-content> | ||
</ul> | ||
<div class="ngx-tree-vr" *ngIf="nodes?.length || nodeElms?.length"></div> | ||
<div class="ngx-tree-vr" *ngIf="(nodes?.length || nodeElms?.length) && !virtualScrolling"></div> | ||
</div> | ||
<ng-template #ngxTreeNode let-node="node"> | ||
<ngx-tree-node | ||
[node]="node" | ||
[disabled]="node.disabled" | ||
[expandable]="node.expandable" | ||
[expanded]="node.expanded" | ||
[selectable]="node.selectable" | ||
[icons]="icons" | ||
[label]="node.label" | ||
[model]="node.model" | ||
[children]="node.children" | ||
[template]="template" | ||
[virtualScrolling]="virtualScrolling" | ||
(expand)="onExpand($event)" | ||
(collapse)="onCollapse($event)" | ||
(activate)="activate.emit($event)" | ||
(deactivate)="deactivate.emit($event)" | ||
(selectNode)="selectNode.emit($event)" | ||
> | ||
</ngx-tree-node> | ||
</ng-template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.