@contrail/document-generation
Advanced tools
Comparing version 2.0.61 to 2.0.62
@@ -32,7 +32,11 @@ "use strict"; | ||
const alignment = template.alignment || 'left'; | ||
const maxComponentHeight = (idealSize.height - template.gridDimensions.rows * componentPadding * 2) / template.gridDimensions.rows; | ||
startingPosition.y += componentPadding; | ||
const rowGap = componentPadding * 3; | ||
const colGap = componentPadding * 2; | ||
const maxComponentHeight = (idealSize.height - template.gridDimensions.rows * colGap) / template.gridDimensions.rows; | ||
startingPosition.y += componentPadding; | ||
for (let row = 0; row < gridTemplate.gridDimensions.rows; row++) { | ||
const remainingItems = data.length - dataIndex; | ||
const itemsInRow = Math.min(remainingItems, gridTemplate.gridDimensions.cols); | ||
const rowWidth = itemsInRow * (componentSize.width + componentPadding * 2) - componentPadding * 2; | ||
const rowWidth = itemsInRow * (componentSize.width + colGap) - colGap; | ||
let rowStartX = startingPosition.x; | ||
@@ -51,5 +55,3 @@ if (alignment === 'center') { | ||
x: rowStartX, | ||
y: startingPosition.y + | ||
row * (Math.min(componentSize.height, maxComponentHeight) + componentPadding * 2) + | ||
componentPadding, | ||
y: startingPosition.y + row * (Math.min(componentSize.height, maxComponentHeight) + rowGap), | ||
}; | ||
@@ -66,3 +68,3 @@ for (let col = 0; col < gridTemplate.gridDimensions.cols; col++) { | ||
dataIndex++; | ||
componentPosition.x += componentSize.width + componentPadding * 2; | ||
componentPosition.x += componentSize.width + colGap; | ||
} | ||
@@ -69,0 +71,0 @@ } |
{ | ||
"name": "@contrail/document-generation", | ||
"version": "2.0.61", | ||
"version": "2.0.62", | ||
"description": "Utilities for automatic generation of documents.", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
1107495
28145