Feature auto margin
Summary: Even so I know there are some opinions against ```margin: 0 auto``` it's still part of the spec: https://www.w3.org/TR/css-flexbox-1/#auto-margins and pretty usefull if you have to position via ```justify-content```. This PR adds an implementation for that. It adds an additonal ```YGUnitAuto``` and margins got ```YGNodeStyleSetMarginAuto``` functions as well. Closes https://github.com/facebook/yoga/pull/357 Reviewed By: astreet Differential Revision: D4501142 Pulled By: emilsjolander fbshipit-source-id: 86519f8632496f46e78a7c9dbc5b21e212e3e0c7
This commit is contained in:
committed by
Facebook Github Bot
parent
8a91c0a0e5
commit
1146013e9e
@@ -119,6 +119,11 @@ void Node::setMarginPercent(int edge, double margin)
|
||||
YGNodeStyleSetMarginPercent(m_node, static_cast<YGEdge>(edge), margin);
|
||||
}
|
||||
|
||||
void Node::setMarginAuto(int edge)
|
||||
{
|
||||
YGNodeStyleSetMarginAuto(m_node, static_cast<YGEdge>(edge));
|
||||
}
|
||||
|
||||
void Node::setOverflow(int overflow)
|
||||
{
|
||||
YGNodeStyleSetOverflow(m_node, static_cast<YGOverflow>(overflow));
|
||||
@@ -164,6 +169,11 @@ void Node::setWidthPercent(double width)
|
||||
YGNodeStyleSetWidthPercent(m_node, width);
|
||||
}
|
||||
|
||||
void Node::setWidthAuto()
|
||||
{
|
||||
YGNodeStyleSetWidthAuto(m_node);
|
||||
}
|
||||
|
||||
void Node::setHeight(double height)
|
||||
{
|
||||
YGNodeStyleSetHeight(m_node, height);
|
||||
@@ -174,6 +184,11 @@ void Node::setHeightPercent(double height)
|
||||
YGNodeStyleSetHeightPercent(m_node, height);
|
||||
}
|
||||
|
||||
void Node::setHeightAuto()
|
||||
{
|
||||
YGNodeStyleSetHeightAuto(m_node);
|
||||
}
|
||||
|
||||
void Node::setMinWidth(double minWidth)
|
||||
{
|
||||
YGNodeStyleSetMinWidth(m_node, minWidth);
|
||||
|
@@ -65,6 +65,7 @@ class Node {
|
||||
|
||||
void setMargin(int edge, double margin);
|
||||
void setMarginPercent(int edge, double margin);
|
||||
void setMarginAuto(int edge);
|
||||
|
||||
void setOverflow(int overflow);
|
||||
void setDisplay(int display);
|
||||
@@ -72,13 +73,16 @@ class Node {
|
||||
void setFlex(double flex);
|
||||
void setFlexBasis(double flexBasis);
|
||||
void setFlexBasisPercent(double flexBasis);
|
||||
void setFlexBasisAuto();
|
||||
void setFlexGrow(double flexGrow);
|
||||
void setFlexShrink(double flexShrink);
|
||||
|
||||
void setWidth(double width);
|
||||
void setWidthPercent(double width);
|
||||
void setWidthAuto();
|
||||
void setHeight(double height);
|
||||
void setHeightPercent(double height);
|
||||
void setHeightAuto();
|
||||
|
||||
void setMinWidth(double minWidth);
|
||||
void setMinWidthPercent(double minWidth);
|
||||
|
@@ -86,10 +86,11 @@ module.exports = {
|
||||
PRINT_OPTIONS_STYLE: 2,
|
||||
PRINT_OPTIONS_CHILDREN: 4,
|
||||
|
||||
UNIT_COUNT: 3,
|
||||
UNIT_COUNT: 4,
|
||||
UNIT_UNDEFINED: 0,
|
||||
UNIT_PIXEL: 1,
|
||||
UNIT_PERCENT: 2,
|
||||
UNIT_AUTO: 3,
|
||||
|
||||
WRAP_COUNT: 2,
|
||||
WRAP_NO_WRAP: 0,
|
||||
|
@@ -107,6 +107,9 @@ module.exports = function (bind, lib) {
|
||||
|
||||
case constants.UNIT_PERCENT:
|
||||
return `${this.value}%`;
|
||||
|
||||
case constants.UNIT_AUTO:
|
||||
return `auto`;
|
||||
|
||||
default: {
|
||||
return `${this.value}?`;
|
||||
|
@@ -65,6 +65,7 @@ NBIND_CLASS(Node)
|
||||
|
||||
method(setMargin);
|
||||
method(setMarginPercent);
|
||||
method(setMarginAuto);
|
||||
|
||||
method(setOverflow);
|
||||
method(setDisplay);
|
||||
@@ -77,8 +78,10 @@ NBIND_CLASS(Node)
|
||||
|
||||
method(setWidth);
|
||||
method(setWidthPercent);
|
||||
method(setWidthAuto);
|
||||
method(setHeight);
|
||||
method(setHeightPercent);
|
||||
method(setHeightAuto);
|
||||
|
||||
method(setMinWidth);
|
||||
method(setMinWidthPercent);
|
||||
|
Reference in New Issue
Block a user