Skip to content

Commit f751c34

Browse files
Yuichi ONOfacebook-github-bot
Yuichi ONO
authored andcommitted
Fix main size calculation from the aspect ratio
Summary: When the following conditions are met, the main size become smaller by the margins in the main axis. * The aspect ratio is defined * The main size is not defined * The cross size is defined * The main margin is defined This is because the main margin size is not included when calculating the main size from the aspect ratio. Closes facebook/yoga#715 Reviewed By: emilsjolander Differential Revision: D6998988 Pulled By: priteshrnandgaonkar fbshipit-source-id: f6f69c47ece17bd7c5e41517b96032bf0c149356
1 parent f7f5dc6 commit f751c34

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

ReactCommon/yoga/yoga/Yoga.cpp

+3-2
Original file line numberDiff line numberDiff line change
@@ -1102,10 +1102,11 @@ static void YGNodeComputeFlexBasisForChild(const YGNodeRef node,
11021102

11031103
if (!YGFloatIsUndefined(child->getStyle().aspectRatio)) {
11041104
if (!isMainAxisRow && childWidthMeasureMode == YGMeasureModeExactly) {
1105-
childHeight = (childWidth - marginRow) / child->getStyle().aspectRatio;
1105+
childHeight = marginColumn +
1106+
(childWidth - marginRow) / child->getStyle().aspectRatio;
11061107
childHeightMeasureMode = YGMeasureModeExactly;
11071108
} else if (isMainAxisRow && childHeightMeasureMode == YGMeasureModeExactly) {
1108-
childWidth =
1109+
childWidth = marginRow +
11091110
(childHeight - marginColumn) * child->getStyle().aspectRatio;
11101111
childWidthMeasureMode = YGMeasureModeExactly;
11111112
}

0 commit comments

Comments
 (0)