Skip to content

Commit 1050e0b

Browse files
woehrl01facebook-github-bot
authored andcommitted
Add justify-content: space-evenly
Summary: Adds new ```space-evenly``` for ```justify-content```. Also adds a typofix in one of the other justify-content tests. Fixes #657 Closes facebook/yoga#658 Differential Revision: D6407996 Pulled By: emilsjolander fbshipit-source-id: cc837409e1345624b4bd72c31e25fe68dcb0f6a3
1 parent 1d62848 commit 1050e0b

File tree

4 files changed

+19
-8
lines changed

4 files changed

+19
-8
lines changed

ReactAndroid/src/main/java/com/facebook/yoga/YogaJustify.java

+4-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ public enum YogaJustify {
1717
CENTER(1),
1818
FLEX_END(2),
1919
SPACE_BETWEEN(3),
20-
SPACE_AROUND(4);
20+
SPACE_AROUND(4),
21+
SPACE_EVENLY(5);
2122

2223
private int mIntValue;
2324

@@ -36,6 +37,8 @@ public static YogaJustify fromInt(int value) {
3637
case 2: return FLEX_END;
3738
case 3: return SPACE_BETWEEN;
3839
case 4: return SPACE_AROUND;
40+
case 5:
41+
return SPACE_EVENLY;
3942
default: throw new IllegalArgumentException("Unknown enum value: " + value);
4043
}
4144
}

ReactCommon/yoga/yoga/YGEnums.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,8 @@ const char *YGJustifyToString(const YGJustify value){
121121
return "space-between";
122122
case YGJustifySpaceAround:
123123
return "space-around";
124+
case YGJustifySpaceEvenly:
125+
return "space-evenly";
124126
}
125127
return "unknown";
126128
}

ReactCommon/yoga/yoga/YGEnums.h

+8-7
Original file line numberDiff line numberDiff line change
@@ -77,13 +77,14 @@ typedef YG_ENUM_BEGIN(YGFlexDirection) {
7777
} YG_ENUM_END(YGFlexDirection);
7878
WIN_EXPORT const char *YGFlexDirectionToString(const YGFlexDirection value);
7979

80-
#define YGJustifyCount 5
81-
typedef YG_ENUM_BEGIN(YGJustify) {
82-
YGJustifyFlexStart,
83-
YGJustifyCenter,
84-
YGJustifyFlexEnd,
85-
YGJustifySpaceBetween,
86-
YGJustifySpaceAround,
80+
#define YGJustifyCount 6
81+
typedef YG_ENUM_BEGIN(YGJustify){
82+
YGJustifyFlexStart,
83+
YGJustifyCenter,
84+
YGJustifyFlexEnd,
85+
YGJustifySpaceBetween,
86+
YGJustifySpaceAround,
87+
YGJustifySpaceEvenly,
8788
} YG_ENUM_END(YGJustify);
8889
WIN_EXPORT const char *YGJustifyToString(const YGJustify value);
8990

ReactCommon/yoga/yoga/Yoga.cpp

+5
Original file line numberDiff line numberDiff line change
@@ -2447,6 +2447,11 @@ static void YGNodelayoutImpl(const YGNodeRef node,
24472447
betweenMainDim = 0;
24482448
}
24492449
break;
2450+
case YGJustifySpaceEvenly:
2451+
// Space is distributed evenly across all elements
2452+
betweenMainDim = remainingFreeSpace / (itemsOnLine + 1);
2453+
leadingMainDim = betweenMainDim;
2454+
break;
24502455
case YGJustifySpaceAround:
24512456
// Space on the edges is half of the space between elements
24522457
betweenMainDim = remainingFreeSpace / itemsOnLine;

0 commit comments

Comments
 (0)