diff --git a/src-ui/app/views/dashboard-view/views/about-view/about-view.component.ts b/src-ui/app/views/dashboard-view/views/about-view/about-view.component.ts index 431c012e..6714d159 100644 --- a/src-ui/app/views/dashboard-view/views/about-view/about-view.component.ts +++ b/src-ui/app/views/dashboard-view/views/about-view/about-view.component.ts @@ -66,15 +66,27 @@ export class AboutViewComponent implements OnInit, AfterViewInit, OnDestroy { this.translationContributors = this.translationContributors.map(cnComplianceFix); } - // Rotate translation contributors matrix diagonally - function mirrorMatrixDiagonally(arr: T[], columns: number): T[] { - const newArr = new Array(arr.length); - const rows = Math.ceil(arr.length / columns); - for (let i = 0; i < arr.length; i++) - newArr[(i % rows) * columns + Math.floor(i / rows)] = arr[i]; - return newArr; + function reorderList(arr: T[], colCount: number): T[] { + // Determine the number of items in each column (row fill order) + const itemsInCol: number[] = []; + const rowCount = Math.ceil(arr.length / colCount); + for (let i = 0; i < colCount; i++) + itemsInCol.push(i < arr.length % colCount ? rowCount : rowCount - 1); + + // Put the items in columns (column fill order) + const columns: T[][] = itemsInCol.reduce((acc, e, i, source) => { + const offset = source.slice(0, i).reduce((_acc, _e) => _acc + _e, 0); + acc[i] = arr.slice(offset, offset + e); + return acc; + }, [] as T[][]); + + // Reconstruct the array from the columns + return new Array(arr.length) + .fill(undefined as T) + .map((_, index) => columns[index % colCount][Math.floor(index / colCount)]); } - this.translationContributors = mirrorMatrixDiagonally(this.translationContributors, 3); + + this.translationContributors = reorderList(this.translationContributors, 3); } async ngOnInit() {