when a node is both stretch and auto, get the result with width and height "null" #644

Closed
opened 2017-10-07 07:16:27 -07:00 by Lizz0y · 5 comments
Lizz0y commented 2017-10-07 07:16:27 -07:00 (Migrated from github.com)

Report

when a node is both cross stretch and margin auto, get the result with width and height "null",i have read the source code and found the following code:

          if (alignItem == YGAlignStretch &&
              YGMarginLeadingValue(child, crossAxis)->unit != YGUnitAuto &&
              YGMarginTrailingValue(child, crossAxis)->unit != YGUnitAuto) {

can someone explain , since the alignItem is already stretch ,auto is meaningless, so why this code exclude the auto ?

# Report when a node is both cross stretch and margin auto, get the result with width and height "null",i have read the source code and found the following code: ``` if (alignItem == YGAlignStretch && YGMarginLeadingValue(child, crossAxis)->unit != YGUnitAuto && YGMarginTrailingValue(child, crossAxis)->unit != YGUnitAuto) { ``` can someone explain , since the alignItem is already stretch ,auto is meaningless, so why this code exclude the auto ?
woehrl01 commented 2017-10-07 08:44:02 -07:00 (Migrated from github.com)

It excludes auto, as if you have a margin of auto, the node should not stretch. Margin is "stronger" than align-item. Thus the node is the size of its content, but it shouldn't be "null". Could you please provide a testcase where it fails, I'll take a look into it.

It excludes auto, as if you have a margin of auto, the node should not stretch. Margin is "stronger" than align-item. Thus the node is the size of its content, but it shouldn't be "null". Could you please provide a testcase where it fails, I'll take a look into it.
Lizz0y commented 2017-10-08 06:03:02 -07:00 (Migrated from github.com)

i write a node with "text" type ,since text has no width&height,so i set a custom measureFunction as:

 YogaNode root = new YogaNode();
 root.setWidth(500);
 root.setHeight(300);

        YogaNode text = new YogaNode();
        text.setMeasureFunction(new YogaMeasureFunction() {
            @Override
            public long measure(YogaNode node, float width, YogaMeasureMode widthMode, float height, YogaMeasureMode heightMode) {
                return new YogaMeasureOutput().make(50,50);
            }
        });
       text.setMarginAuto(YogaEdge.LEFT);
        root.addChildAt(text, 0);

when i run this code ,find the text node return "null" for both height and width, please find what's wrong with it ,thx

i write a node with "text" type ,since text has no width&height,so i set a custom measureFunction as: ``` YogaNode root = new YogaNode(); root.setWidth(500); root.setHeight(300); YogaNode text = new YogaNode(); text.setMeasureFunction(new YogaMeasureFunction() { @Override public long measure(YogaNode node, float width, YogaMeasureMode widthMode, float height, YogaMeasureMode heightMode) { return new YogaMeasureOutput().make(50,50); } }); text.setMarginAuto(YogaEdge.LEFT); root.addChildAt(text, 0); ``` when i run this code ,find the text node return "null" for both height and width, please find what's wrong with it ,thx
woehrl01 commented 2017-10-08 07:38:17 -07:00 (Migrated from github.com)

It should be a width and height of 50 and left 450 here. I'll reproduce and have a look.

It should be a width and height of 50 and left 450 here. I'll reproduce and have a look.
woehrl01 commented 2017-10-08 10:40:30 -07:00 (Migrated from github.com)

thank you for the hint @Lizz0y , I pushed a fix for this in #645

thank you for the hint @Lizz0y , I pushed a fix for this in #645
Lizz0y commented 2017-10-10 01:38:57 -07:00 (Migrated from github.com)

thx @woehrl01 for fix this problem

thx @woehrl01 for fix this problem
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: DaddyFrosty/yoga#644
No description provided.