diff --git a/src/Layout.js b/src/Layout.js index 0003b3b6..bdcd7e11 100755 --- a/src/Layout.js +++ b/src/Layout.js @@ -135,7 +135,6 @@ var computeLayout = (function() { return !isUndefined(node.style[pos]); } - function getPosition(node, pos) { if (pos in node.style) { return node.style[pos]; @@ -293,15 +292,15 @@ var computeLayout = (function() { } } } + mainPos += getPaddingAndBorder(node, trailing[mainAxis]); - crossDim += getPaddingAndBorder(node, leading[crossAxis]) + - getPaddingAndBorder(node, trailing[crossAxis]); + crossDim += getPaddingAndBorderAxis(node, crossAxis); if (isUndefined(node.layout[dim[mainAxis]]) && !mainDimInStyle) { - node.layout[dim[mainAxis]] = mainPos > 0 ? mainPos : 0; + node.layout[dim[mainAxis]] = fmaxf(mainPos, getPaddingAndBorderAxis(node, mainAxis)); } if (isUndefined(node.layout[dim[crossAxis]])) { - node.layout[dim[crossAxis]] = crossDim > 0 ? crossDim : 0; + node.layout[dim[crossAxis]] = fmaxf(crossDim, getPaddingAndBorderAxis(node, crossAxis)); } for (var/*int*/ i = 0; i < node.children.length; ++i) { diff --git a/src/__tests__/Layout-test.js b/src/__tests__/Layout-test.js index f8f847a1..2a8ed965 100755 --- a/src/__tests__/Layout-test.js +++ b/src/__tests__/Layout-test.js @@ -733,7 +733,16 @@ describe('Layout', function() { ); }); - + it('should handle negative margin and min padding correctly', function() { + testLayout( + {style: {borderRightWidth: 1, flexDirection: 'row'}, children: [ + {style: {marginRight: -8}} + ]}, + {width: 1, height: 0, top: 0, left: 0, children: [ + {width: 0, height: 0, top: 0, left: 0} + ]} + ) + });