Skip to content

Commit

Permalink
alignment: edit the behaviour of distribute_grid_row
Browse files Browse the repository at this point in the history
now the returned diagram's children is the distributed
diagrams instead of list of list of diagrams
  • Loading branch information
ray-pH committed Feb 8, 2024
1 parent bb98ccc commit 4d97800
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/alignment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,8 @@ export function distribute_vertical_and_align(diagrams : Diagram[], vertical_spa
* @param column_count number of columns
* @param vectical_space space between the diagrams vertically (default = 0)
* @param horizontal_space space between the diagrams horizontally (default = 0)
* NODE: the behaviour is updated in v1.3.0
* (now the returned diagram's children is the distributed diagrams instead of list of list of diagrams)
*/
export function distribute_grid_row(diagrams : Diagram[], column_count : number,
vectical_space : number = 0, horizontal_space : number = 0,
Expand All @@ -177,5 +179,12 @@ export function distribute_grid_row(diagrams : Diagram[], column_count : number,
}
let distributed_rows = rows.map(row => distribute_horizontal(row, horizontal_space));
let distributed_diagrams = distribute_vertical(distributed_rows, vectical_space);
return distributed_diagrams;

let grid_diagrams = []
for (let i = 0; i < distributed_diagrams.children.length; i++) {
for (let j = 0; j < distributed_diagrams.children[i].children.length; j++) {
grid_diagrams.push(distributed_diagrams.children[i].children[j]);
}
}
return diagram_combine(...grid_diagrams);
}

0 comments on commit 4d97800

Please sign in to comment.