Permalink
Browse files

Fix flex-wrap with max constraint

Summary:
Fixes `flex-wrap` with a max constraint and `justify-content`. Fixes facebook/yoga#514.
Closes facebook/yoga#519

Differential Revision: D4953727

Pulled By: emilsjolander

fbshipit-source-id: 32dec48220be1392ea8dac5f34871d407eb8d49b
  • Loading branch information...
woehrl01 authored and facebook-github-bot committed Apr 26, 2017
1 parent c7e0f56 commit c660d0c8363165b42412fb39b4321d048dd53253
Showing with 12 additions and 6 deletions.
  1. +12 −6 ReactCommon/yoga/yoga/Yoga.c
@@ -2141,23 +2141,29 @@ static void YGNodelayoutImpl(const YGNodeRef node,
if (child->style.positionType != YGPositionTypeAbsolute) {
const float childMarginMainAxis = YGNodeMarginForAxis(child, mainAxis, availableInnerWidth);
const float outerFlexBasis =
const float flexBasisWithMaxConstraints =
fminf(YGResolveValue(&child->style.maxDimensions[dim[mainAxis]], mainAxisParentSize),
fmaxf(YGResolveValue(&child->style.minDimensions[dim[mainAxis]],
mainAxisParentSize),
child->layout.computedFlexBasis));
const float flexBasisWithMinAndMaxConstraints =
fmaxf(YGResolveValue(&child->style.minDimensions[dim[mainAxis]], mainAxisParentSize),
child->layout.computedFlexBasis) +
childMarginMainAxis;
flexBasisWithMaxConstraints);
// If this is a multi-line flow and this item pushes us over the
// available size, we've
// hit the end of the current line. Break out of the loop and lay out
// the current line.
if (sizeConsumedOnCurrentLineIncludingMinConstraint + outerFlexBasis >
if (sizeConsumedOnCurrentLineIncludingMinConstraint + flexBasisWithMinAndMaxConstraints +
childMarginMainAxis >
availableInnerMainDim &&
isNodeFlexWrap && itemsOnLine > 0) {
break;
}
sizeConsumedOnCurrentLineIncludingMinConstraint += outerFlexBasis;
sizeConsumedOnCurrentLine += child->layout.computedFlexBasis + childMarginMainAxis;
sizeConsumedOnCurrentLineIncludingMinConstraint +=
flexBasisWithMinAndMaxConstraints + childMarginMainAxis;
sizeConsumedOnCurrentLine += flexBasisWithMaxConstraints + childMarginMainAxis;
itemsOnLine++;
if (YGNodeIsFlex(child)) {

0 comments on commit c660d0c

Please sign in to comment.