stretch and padding round 2

This commit is contained in:
Christopher Chedeau
2014-04-16 13:32:05 -07:00
parent 5a653ef94b
commit a67c193bef
2 changed files with 14 additions and 0 deletions

View File

@@ -512,6 +512,18 @@ describe('Layout', function() {
);
});
it('should layout node with inner & outer padding and stretch', function() {
testLayout(
{style: {padding: 50}, children: [
{style: {padding: 10, alignSelf: 'stretch'}}
]},
{width: 120, height: 120, top: 0, left: 0, children: [
{width: 20, height: 20, top: 50, left: 50}
]}
);
});
it('should layout randomly', function() {
function RNG(seed) {
this.state = seed;

View File

@@ -203,6 +203,8 @@ function computeLayout(node) {
leadingCrossDim += remainingCrossDim;
} else if (alignItem === 'stretch') {
child.layout[dim[crossAxis]] += node.layout[dim[crossAxis]] -
getPadding(node, leading[crossAxis]) -
getPadding(node, trailing[crossAxis]) -
getMargin(child, leading[crossAxis]) -
getMargin(child, trailing[crossAxis]) -
getPadding(child, leading[crossAxis]) -