Skip to content

Commit

Permalink
Fix align-content: center, flex-end alignment with margin
Browse files Browse the repository at this point in the history
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 18c239e
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions ReactCommon/yoga/yoga/Yoga.c
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 18c239e

Please sign in to comment.