Skip to content

Commit

Permalink
Correct logic for adding blanks sections when numPerPage > 1
Browse files Browse the repository at this point in the history
  • Loading branch information
floogulinc committed Jan 3, 2021
1 parent 15d5b43 commit 6e0739b
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/app/pages/marker-generator/marker-generator.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ interface Page {
* The marker number.
*/
value: string;

type: 'Flower' | 'Nest';

/**
* The marker image, as SVG source code.
*/
Expand Down Expand Up @@ -153,9 +153,10 @@ export class MarkerGeneratorComponent implements OnInit {

const backgroundSVGPages = chunk(pages.map(p => p.backgroundSVG), numPerPage);

if (numPerPage > 1 && pages.length % 2) {
columnPages.push([...columnPages.pop(), []]);
backgroundSVGPages.push([...backgroundSVGPages.pop(), blankSVG]);
if (numPerPage > 1 && pages.length % numPerPage) {
const extraColumns = numPerPage - (pages.length % numPerPage);
columnPages.push([...columnPages.pop(), ...new Array(extraColumns).fill([])]);
backgroundSVGPages.push([...backgroundSVGPages.pop(), ...new Array(extraColumns).fill(blankSVG)]);
}

const content: Content[] = columnPages.map((c, i, arr) => ({
Expand Down

0 comments on commit 6e0739b

Please sign in to comment.