diff --git a/src/index.js b/src/index.js index 90a83c0..5900c1c 100644 --- a/src/index.js +++ b/src/index.js @@ -16,7 +16,7 @@ function getRowLayout(photos, containerWidth, targetRowHeight = 300) { containerWidth, limitNodeSearch, targetRowHeight, - margin: 0, + margin: 2, photos, }); @@ -55,10 +55,10 @@ function getPositions(rows) { let x = 0; const position = row.map((thumb) => { const thumbX = x; - x += thumb.width; + x += (thumb.width + thumb.margin); return { x: thumbX, y }; }); - y += row[0].height; + y += (row[0].height + row[0].margin); return position; }); } diff --git a/src/layouts/justified.js b/src/layouts/justified.js index 18f1332..fc21068 100755 --- a/src/layouts/justified.js +++ b/src/layouts/justified.js @@ -71,6 +71,7 @@ export const computeRowLayout = ({ for (let j = path[i - 1]; j < path[i]; ++j) { photos[j].width = round(height * ratio(photos[j]), 1); photos[j].height = height; + photos[j].margin = margin; } } return photos;