From 5a653ef94b0dfd3930d4f56637b8268120654796 Mon Sep 17 00:00:00 2001 From: Christopher Chedeau Date: Wed, 16 Apr 2014 13:21:30 -0700 Subject: [PATCH] padding and stretch --- spec/LayoutSpec.js | 11 +++++++++++ src/Layout.js | 4 +++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/spec/LayoutSpec.js b/spec/LayoutSpec.js index dc99bc17..3520d81e 100755 --- a/spec/LayoutSpec.js +++ b/spec/LayoutSpec.js @@ -501,6 +501,17 @@ describe('Layout', function() { ); }); + it('should layout node with padding and stretch', function() { + testLayout( + {style: {}, children: [ + {style: {padding: 10, alignSelf: 'stretch'}} + ]}, + {width: 20, height: 20, top: 0, left: 0, children: [ + {width: 20, height: 20, top: 0, left: 0} + ]} + ); + }); + it('should layout randomly', function() { function RNG(seed) { this.state = seed; diff --git a/src/Layout.js b/src/Layout.js index 5eb3025a..ea821b33 100755 --- a/src/Layout.js +++ b/src/Layout.js @@ -204,7 +204,9 @@ function computeLayout(node) { } else if (alignItem === 'stretch') { child.layout[dim[crossAxis]] += node.layout[dim[crossAxis]] - getMargin(child, leading[crossAxis]) - - getMargin(child, trailing[crossAxis]); + getMargin(child, trailing[crossAxis]) - + getPadding(child, leading[crossAxis]) - + getPadding(child, trailing[crossAxis]); } child.layout[pos[crossAxis]] += leadingCrossDim; });