Skip to content

Commit

Permalink
Fix position on root node with RTL direction
Browse files Browse the repository at this point in the history
Summary:
If the root node has a position and we have a RTL layout, that position must be like LTR direction. See #477.
Closes facebook/yoga#502

Differential Revision: D4867144

Pulled By: emilsjolander

fbshipit-source-id: b5ad3d87e7054090da12d7665a3d1abe8496a548
  • Loading branch information
woehrl01 authored and facebook-github-bot committed Apr 11, 2017
1 parent 7da07fa commit f7fe9a6
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions ReactCommon/yoga/yoga/Yoga.c
Original file line number Diff line number Diff line change
Expand Up @@ -1324,8 +1324,12 @@ static void YGNodeSetPosition(const YGNodeRef node,
const float mainSize,
const float crossSize,
const float parentWidth) {
const YGFlexDirection mainAxis = YGResolveFlexDirection(node->style.flexDirection, direction);
const YGFlexDirection crossAxis = YGFlexDirectionCross(mainAxis, direction);
/* Root nodes should be always layouted as LTR, so we don't return negative values. */
const YGDirection directionRespectingRoot = node->parent != NULL ? direction : YGDirectionLTR;
const YGFlexDirection mainAxis =
YGResolveFlexDirection(node->style.flexDirection, directionRespectingRoot);
const YGFlexDirection crossAxis = YGFlexDirectionCross(mainAxis, directionRespectingRoot);

const float relativePositionMain = YGNodeRelativePosition(node, mainAxis, mainSize);
const float relativePositionCross = YGNodeRelativePosition(node, crossAxis, crossSize);

Expand Down

0 comments on commit f7fe9a6

Please sign in to comment.