mirror of
https://github.com/zhigang1992/sass-layout.git
synced 2026-04-29 03:35:08 +08:00
should layout node with justifyContent: space-around
This commit is contained in:
@@ -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
|
||||
|
||||
11
test.scss
11
test.scss
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user