it should apply padding on the node itself
This commit is contained in:
@@ -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() {
|
it('should layout randomly', function() {
|
||||||
function RNG(seed) {
|
function RNG(seed) {
|
||||||
this.state = seed;
|
this.state = seed;
|
||||||
|
@@ -36,7 +36,7 @@ function computeLayout(node) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (type in node.style) {
|
if (type in node.style) {
|
||||||
return node.style.margin;
|
return node.style[type];
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
@@ -164,8 +164,8 @@ function computeLayout(node) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var crossDim = 0;
|
var crossDim = getPadding(leading[crossAxis], node);
|
||||||
var mainPos = leadingMainDim;
|
var mainPos = getPadding(leading[mainAxis], node) + leadingMainDim;
|
||||||
children.forEach(function(child) {
|
children.forEach(function(child) {
|
||||||
child.layout[pos[mainAxis]] += mainPos;
|
child.layout[pos[mainAxis]] += mainPos;
|
||||||
mainPos += getDimWithMargin(child, mainAxis) + betweenMainDim;
|
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) {
|
if (node.layout[dim[mainAxis]] === undefined && !mainDimInStyle) {
|
||||||
node.layout[dim[mainAxis]] = Math.max(mainPos, 0);
|
node.layout[dim[mainAxis]] = Math.max(mainPos, 0);
|
||||||
|
Reference in New Issue
Block a user