cross padding and margin

This commit is contained in:
Christopher Chedeau
2014-04-16 13:15:00 -07:00
parent d6abb5d51f
commit 04fefdb87a
2 changed files with 14 additions and 2 deletions

View File

@@ -490,6 +490,17 @@ describe('Layout', function() {
);
});
it('should layout node with padding and a child with margin', function() {
testLayout(
{style: {padding: 5}, children: [
{style: {margin: 5}}
]},
{width: 20, height: 20, top: 0, left: 0, children: [
{width: 0, height: 0, top: 10, left: 10}
]}
);
});
it('should layout randomly', function() {
function RNG(seed) {
this.state = seed;

View File

@@ -164,7 +164,7 @@ function computeLayout(node) {
}
}
var crossDim = getPadding(node, leading[crossAxis]);
var crossDim = 0;
var mainPos = getPadding(node, leading[mainAxis]) + leadingMainDim;
children.forEach(function(child) {
child.layout[pos[mainAxis]] += mainPos;
@@ -178,7 +178,8 @@ function computeLayout(node) {
}
});
mainPos += getPadding(node, trailing[mainAxis]);
crossDim += getPadding(node, trailing[crossAxis]);
crossDim += getPadding(node, leading[crossAxis]) +
getPadding(node, trailing[crossAxis]);
if (node.layout[dim[mainAxis]] === undefined && !mainDimInStyle) {
node.layout[dim[mainAxis]] = Math.max(mainPos, 0);