space-around with padding
This commit is contained in:
@@ -533,7 +533,6 @@ describe('Layout', function() {
|
|||||||
{style: {margin: 16}}
|
{style: {margin: 16}}
|
||||||
]}
|
]}
|
||||||
]},
|
]},
|
||||||
|
|
||||||
{width: 32, height: 32, top: 0, left: 0, children: [
|
{width: 32, height: 32, top: 0, left: 0, children: [
|
||||||
{width: 32, height: 32, top: 0, left: 0, children: [
|
{width: 32, height: 32, top: 0, left: 0, children: [
|
||||||
{width: 0, height: 0, top: 16, left: 16}
|
{width: 0, height: 0, top: 16, left: 16}
|
||||||
@@ -542,13 +541,24 @@ describe('Layout', function() {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should layout node with top', function() {
|
it('should layout node with top and left', function() {
|
||||||
testLayout(
|
testLayout(
|
||||||
{style: {top: 5, left: 5}},
|
{style: {top: 5, left: 5}},
|
||||||
{width: 0, height: 0, top: 5, left: 5}
|
{width: 0, height: 0, top: 5, left: 5}
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should layout node with height, padding and space-around', function() {
|
||||||
|
testLayout(
|
||||||
|
{style : {height: 10, paddingTop: 5, justifyContent: 'space-around'}, children: [
|
||||||
|
{style: {}}
|
||||||
|
]},
|
||||||
|
{width: 0, height: 10, top: 0, left: 0, children: [
|
||||||
|
{width: 0, height: 0, top: 7.5, left: 0}
|
||||||
|
]}
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
it('should layout randomly', function() {
|
it('should layout randomly', function() {
|
||||||
function RNG(seed) {
|
function RNG(seed) {
|
||||||
this.state = seed;
|
this.state = seed;
|
||||||
@@ -589,6 +599,8 @@ describe('Layout', function() {
|
|||||||
var node = {style: {}};
|
var node = {style: {}};
|
||||||
randMinMax(node, 0.1, 'width', 0, 1000);
|
randMinMax(node, 0.1, 'width', 0, 1000);
|
||||||
randMinMax(node, 0.1, 'height', 0, 1000);
|
randMinMax(node, 0.1, 'height', 0, 1000);
|
||||||
|
randMinMax(node, 0.1, 'top', 0, 10);
|
||||||
|
randMinMax(node, 0.1, 'left', 0, 10);
|
||||||
randSpacing(node, 0.1, 'margin', 0, 20);
|
randSpacing(node, 0.1, 'margin', 0, 20);
|
||||||
randSpacing(node, 0.1, 'padding', 0, 20);
|
randSpacing(node, 0.1, 'padding', 0, 20);
|
||||||
randEnum(node, 0.1, 'flexDirection', ['row', 'column']);
|
randEnum(node, 0.1, 'flexDirection', ['row', 'column']);
|
||||||
|
@@ -145,7 +145,11 @@ function computeLayout(node) {
|
|||||||
var leadingMainDim = 0;
|
var leadingMainDim = 0;
|
||||||
var betweenMainDim = 0;
|
var betweenMainDim = 0;
|
||||||
if (node.layout[dim[mainAxis]] !== undefined) {
|
if (node.layout[dim[mainAxis]] !== undefined) {
|
||||||
var remainingMainDim = node.layout[dim[mainAxis]] - mainContentDim;
|
var remainingMainDim = node.layout[dim[mainAxis]] -
|
||||||
|
getPadding(node, leading[mainAxis]) -
|
||||||
|
getPadding(node, trailing[mainAxis]) -
|
||||||
|
mainContentDim;
|
||||||
|
|
||||||
if (flexibleChildrenCount) {
|
if (flexibleChildrenCount) {
|
||||||
var flexibleMainDim = remainingMainDim / flexibleChildrenCount;
|
var flexibleMainDim = remainingMainDim / flexibleChildrenCount;
|
||||||
children.forEach(function(child) {
|
children.forEach(function(child) {
|
||||||
@@ -201,6 +205,7 @@ function computeLayout(node) {
|
|||||||
getDimWithMargin(child, crossAxis) -
|
getDimWithMargin(child, crossAxis) -
|
||||||
getPadding(node, leading[crossAxis]) -
|
getPadding(node, leading[crossAxis]) -
|
||||||
getPadding(node, trailing[crossAxis]);
|
getPadding(node, trailing[crossAxis]);
|
||||||
|
|
||||||
var leadingCrossDim = getPadding(node, leading[crossAxis]);
|
var leadingCrossDim = getPadding(node, leading[crossAxis]);
|
||||||
if (alignItem === 'flex-start') {
|
if (alignItem === 'flex-start') {
|
||||||
// Do nothing
|
// Do nothing
|
||||||
|
Reference in New Issue
Block a user