Permalink
Browse files

Fix align-content: center, flex-end alignment with margin

Summary:
This fixes ```align-content: center``` and ```align-content: flex-end``` when the child exceeds the parents size. See #476. It also fixes those layouts if the child has ```margin: auto``` set.
Closes facebook/yoga#477

Differential Revision: D4697833

Pulled By: emilsjolander

fbshipit-source-id: d081ec7ea559a5f2bd3271c3a4dc272960beddfa
  • Loading branch information...
woehrl01 authored and facebook-github-bot committed Mar 15, 2017
1 parent 6cbb57d commit 18c239ee22adf55f9698c03066c033d7992bfaa0
Showing with 2 additions and 6 deletions.
  1. +2 −6 ReactCommon/yoga/yoga/Yoga.c
@@ -2624,10 +2624,6 @@ static void YGNodelayoutImpl(const YGNodeRef node,
crossAxisParentSize,
parentWidth) -
paddingAndBorderAxisCross;
if (measureModeCrossDim == YGMeasureModeAtMost) {
containerCrossAxis = fminf(containerCrossAxis, availableInnerCrossDim);
}
}
// If there's no flex wrap, the cross dimension is defined by the container.
@@ -2735,11 +2731,11 @@ static void YGNodelayoutImpl(const YGNodeRef node,
if (YGMarginLeadingValue(child, crossAxis)->unit == YGUnitAuto &&
YGMarginTrailingValue(child, crossAxis)->unit == YGUnitAuto) {
leadingCrossDim += remainingCrossDim / 2;
leadingCrossDim += fmaxf(0.0f, remainingCrossDim / 2);
} else if (YGMarginTrailingValue(child, crossAxis)->unit == YGUnitAuto) {
// No-Op
} else if (YGMarginLeadingValue(child, crossAxis)->unit == YGUnitAuto) {
leadingCrossDim += remainingCrossDim;
leadingCrossDim += fmaxf(0.0f, remainingCrossDim);
} else if (alignItem == YGAlignFlexStart) {
// No-Op
} else if (alignItem == YGAlignCenter) {

0 comments on commit 18c239e

Please sign in to comment.