Skip to content

Commit

Permalink
Properly handling a 0 value containerPadding config parameter.
Browse files Browse the repository at this point in the history
  • Loading branch information
jimwhimpey committed Mar 29, 2016
1 parent c3fceae commit 9be4ac8
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
4 changes: 2 additions & 2 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -170,9 +170,9 @@ function computeLayout(itemLayoutData) {

// We need to clean up the bottom container padding
// First remove the height added for box spacing
layoutData._containerHeight = layoutData._containerHeight - (layoutConfig.boxSpacing.vertical || layoutConfig.boxSpacing);
layoutData._containerHeight = layoutData._containerHeight - layoutConfig.boxSpacing.vertical;
// Then add our bottom container padding
layoutData._containerHeight = layoutData._containerHeight + (layoutConfig.containerPadding.bottom || layoutConfig.containerPadding);
layoutData._containerHeight = layoutData._containerHeight + layoutConfig.containerPadding.bottom;

return {
containerHeight: layoutData._containerHeight,
Expand Down
4 changes: 2 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -173,9 +173,9 @@ function computeLayout(itemLayoutData) {

// We need to clean up the bottom container padding
// First remove the height added for box spacing
layoutData._containerHeight = layoutData._containerHeight - (layoutConfig.boxSpacing.vertical || layoutConfig.boxSpacing);
layoutData._containerHeight = layoutData._containerHeight - layoutConfig.boxSpacing.vertical;
// Then add our bottom container padding
layoutData._containerHeight = layoutData._containerHeight + (layoutConfig.containerPadding.bottom || layoutConfig.containerPadding);
layoutData._containerHeight = layoutData._containerHeight + layoutConfig.containerPadding.bottom;

return {
containerHeight: layoutData._containerHeight,
Expand Down
11 changes: 11 additions & 0 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,17 @@ describe('justified-layout', function() {

});

it('should handle 0 padding', function() {

var geometry = justifiedLayout([1, 1, 1], {
containerPadding: 0,
targetRowHeightTolerance: 0
});

expect(geometry.containerHeight).toEqual(320);

});

});

});

0 comments on commit 9be4ac8

Please sign in to comment.