padding and stretch

This commit is contained in:
Christopher Chedeau
2014-04-16 13:21:30 -07:00
parent 04fefdb87a
commit 5a653ef94b
2 changed files with 14 additions and 1 deletions

View File

@@ -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;

View File

@@ -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;
});