optimisation
This commit is contained in:
@@ -12,7 +12,7 @@ import { CommonModule } from '@angular/common';
|
||||
@for (item of [1,2,3,4,5]; track item) {
|
||||
<div class="skeleton-tree-item">
|
||||
<div class="skeleton-circle"></div>
|
||||
<div class="skeleton-line" [style.width]="getRandomWidth()"></div>
|
||||
<div class="skeleton-line" [style.width]="treeWidths[item - 1]"></div>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
@@ -159,8 +159,8 @@ import { CommonModule } from '@angular/common';
|
||||
export class LoadingSkeletonComponent {
|
||||
@Input() type: 'tree' | 'card' | 'list' | 'form' = 'list';
|
||||
|
||||
getRandomWidth(): string {
|
||||
const widths = ['60%', '70%', '80%', '90%'];
|
||||
return widths[Math.floor(Math.random() * widths.length)];
|
||||
}
|
||||
/** Pre-computed widths so they don't change between CD cycles (NG0100). */
|
||||
readonly treeWidths = [1, 2, 3, 4, 5].map(
|
||||
(_, i) => ['60%', '80%', '70%', '90%', '75%'][i]
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user