Skip to content

Commit

Permalink
The total flex factores need to be a minimum of 1 if any
Browse files Browse the repository at this point in the history
Summary:
The only thing I found in the spec for this change is the following. Not exactly sure if this is the thing this PR is about:

> For each flex item, subtract its outer flex base size from its max-content contribution size. If that result is not zero, divide it by (if the result was positive) its **flex grow factor floored at 1** or (if the result was negative) by its scaled flex shrink factor, having **floored the flex shrink factor at 1**. This is the item’s max-content flex fraction.

But at least it seems a required change.

Fixes facebook/yoga#566
Closes facebook/yoga#572

Differential Revision: D5264388

Pulled By: emilsjolander

fbshipit-source-id: 0004d1c3b9bad070a98cd6766c1adc06a54475f8
  • Loading branch information
woehrl01 authored and facebook-github-bot committed Jun 16, 2017
1 parent 8fa55ca commit 3b93ba9
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions ReactCommon/yoga/yoga/Yoga.c
Original file line number Diff line number Diff line change
Expand Up @@ -2278,6 +2278,16 @@ static void YGNodelayoutImpl(const YGNodeRef node,
}
}

// The total flex factor needs to be floored to 1.
if (totalFlexGrowFactors > 0 && totalFlexGrowFactors < 1) {
totalFlexGrowFactors = 1;
}

// The total flex shrink factor needs to be floored to 1.
if (totalFlexShrinkScaledFactors > 0 && totalFlexShrinkScaledFactors < 1) {
totalFlexShrinkScaledFactors = 1;
}

// If we don't need to measure the cross axis, we can skip the entire flex
// step.
const bool canSkipFlex = !performLayout && measureModeCrossDim == YGMeasureModeExactly;
Expand Down

0 comments on commit 3b93ba9

Please sign in to comment.