better handling for padding in a top/bottom or left/right configuration

This commit is contained in:
Christopher Chedeau
2014-06-12 11:52:07 -07:00
parent 900beefa1e
commit a36820d15e
2 changed files with 39 additions and 8 deletions

View File

@@ -490,12 +490,13 @@ var computeLayout = (function() {
getPaddingAndBorderAxis(node, mainAxis)
);
} else {
child.layout[dim[mainAxis]] = fmaxf(0,
child.layout[dim[mainAxis]] = fmaxf(
getPaddingAndBorderAxis(child, mainAxis),
node.layout[dim[mainAxis]] -
child.layout[pos[mainAxis]] -
getMargin(child, trailing[mainAxis]) -
getPosition(child, trailing[mainAxis])
) + getPaddingAndBorderAxis(child, mainAxis);
);
}
}
}
@@ -528,12 +529,20 @@ var computeLayout = (function() {
getPosition(child, trailing[crossAxis]);
}
if (leadingPos && trailingPos) {
child.layout[dim[crossAxis]] = fmaxf(0,
node.layout[dim[crossAxis]] -
child.layout[pos[crossAxis]] -
getMargin(child, trailing[crossAxis]) -
getPosition(child, trailing[crossAxis])
);
if (isDimDefined(child, crossAxis)) {
child.layout[dim[crossAxis]] = fmaxf(
child.style[dim[crossAxis]],
getPaddingAndBorderAxis(node, crossAxis)
);
} else {
child.layout[dim[crossAxis]] = fmaxf(
getPaddingAndBorderAxis(child, crossAxis),
node.layout[dim[crossAxis]] -
child.layout[pos[crossAxis]] -
getMargin(child, trailing[crossAxis]) -
getPosition(child, trailing[crossAxis])
);
}
}
} else {
var/*float*/ leadingCrossDim = getPaddingAndBorder(node, leading[crossAxis]);

View File

@@ -983,6 +983,28 @@ describe('Layout', function() {
);
});
it('should layout with position absolute left, right and width', function() {
testLayout(
{style: {}, children: [
{style: {left: 5, right: -1, width: 300, position: 'absolute'}}
]},
{width: 0, height: 0, top: 0, left: 0, children: [
{width: 300, height: 0, top: 0, left: 5}
]}
);
});
it('should layout with position absolute top, bottom and min padding', function() {
testLayout(
{style: {}, children: [
{style: {top: -5, bottom: -5, paddingTop: 5, position: 'absolute'}}
]},
{width: 0, height: 0, top: 0, left: 0, children: [
{width: 0, height: 10, top: -5, left: 0}
]}
);
});
xit('should layout text with alignItems: stretch', function() {
testLayout(
{style: {width: 80, padding: 7, alignItems: 'stretch', measure: text('loooooooooong with space')}},