should layout node with justifyContent: space-around

This commit is contained in:
Kyle Fang
2015-02-02 12:39:11 +08:00
parent fd0abd2c92
commit 559cb77e6a
2 changed files with 20 additions and 0 deletions

View File

@@ -102,6 +102,15 @@ $global-frame-map: () !global;
} @else if($justify-content == space-between) {
$flex-point-to-add: length($child-nodes) - 1;
$child-nodes: join-list-with-item($child-nodes, $fake-node);
} @else if($justify-content == space-around) {
$flex-point-to-add: length($child-nodes);
$fake-half-node: map-merge(empty-layout(), (
parent-selector: map-get($node, selector),
flex: 0.5
));
$child-nodes: join-list-with-item($child-nodes, $fake-node);
$child-nodes: join(($fake-half-node,), $child-nodes);
$child-nodes: append($child-nodes, $fake-half-node);
}
$node: map-merge($node, (
flex-total: map-get($node, flex-total) + $flex-point-to-add

View File

@@ -138,6 +138,17 @@
@include assert-equal(render-node('.r .c_a'), (100, 100, 0, 0));
@include assert-equal(render-node('.r .c_b'), (100, 100, 900, 0));
}
@include test('should layout node with justifyContent: space-around') {
.r {
@include layout(( width: 1000, height: 1000, justify-content: space-around ));
.c_a { @include layout(( width: 100, height: 100 )) }
.c_b { @include layout(( width: 100, height: 100 )) }
}
@include render-layout;
@include assert-equal(render-node('.r .c_a'), (100, 100, 200, 0));
@include assert-equal(render-node('.r .c_b'), (100, 100, 700, 0));
}
}
@include report;