it should apply padding on the node itself

This commit is contained in:
Christopher Chedeau
2014-04-15 18:24:37 -07:00
parent 9db106a71c
commit 36d6108e8d
2 changed files with 12 additions and 3 deletions

View File

@@ -472,6 +472,13 @@ describe('Layout', function() {
);
});
it('should layout node with padding', function() {
testLayout(
{style: {padding: 5}},
{width: 10, height: 10, top: 0, left: 0}
);
});
it('should layout randomly', function() {
function RNG(seed) {
this.state = seed;

View File

@@ -36,7 +36,7 @@ function computeLayout(node) {
}
if (type in node.style) {
return node.style.margin;
return node.style[type];
}
return 0;
@@ -164,8 +164,8 @@ function computeLayout(node) {
}
}
var crossDim = 0;
var mainPos = leadingMainDim;
var crossDim = getPadding(leading[crossAxis], node);
var mainPos = getPadding(leading[mainAxis], node) + leadingMainDim;
children.forEach(function(child) {
child.layout[pos[mainAxis]] += mainPos;
mainPos += getDimWithMargin(child, mainAxis) + betweenMainDim;
@@ -177,6 +177,8 @@ function computeLayout(node) {
}
}
});
mainPos += getPadding(trailing[mainAxis], node);
crossDim += getPadding(trailing[crossAxis], node);
if (node.layout[dim[mainAxis]] === undefined && !mainDimInStyle) {
node.layout[dim[mainAxis]] = Math.max(mainPos, 0);