Added property display: flex and none
Summary: Fix #241 and successor for #302 Added new property ```display``` with ```YGDisplayFlex``` and ```YGDisplayNone```. Allows to hide nodes from the layout without the need to remove it from the DOM. Closes https://github.com/facebook/yoga/pull/369 Reviewed By: astreet Differential Revision: D4501141 Pulled By: emilsjolander fbshipit-source-id: 0dfeee381f6d1e4bbba81926126b83dd7abab9d6
This commit is contained in:
committed by
Facebook Github Bot
parent
c1cdc1de58
commit
e567502750
@@ -140,6 +140,7 @@ function checkDefaultValues() {
|
||||
{style:'top', value:'undefined'},
|
||||
{style:'right', value:'undefined'},
|
||||
{style:'bottom', value:'undefined'},
|
||||
{style:'display', value:'flex'},
|
||||
].forEach(function(item) {
|
||||
assert(item.value === getDefaultStyleValue(item.style),
|
||||
item.style + ' should be ' + item.value);
|
||||
@@ -300,6 +301,9 @@ function setupTestTree(e, parent, node, genericNode, nodeName, parentName, index
|
||||
case 'max-height':
|
||||
e.YGNodeStyleSetMaxHeight(nodeName, pixelValue(e, node.style[style]));
|
||||
break;
|
||||
case 'display':
|
||||
e.YGNodeStyleSetDisplay(nodeName, displayValue(e, node.style[style]))
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -389,6 +393,13 @@ function pixelValue(e, value) {
|
||||
}
|
||||
}
|
||||
|
||||
function displayValue(e, value){
|
||||
switch(value){
|
||||
case 'flex': return e.YGDisplayFlex;
|
||||
case 'none': return e.YGDisplayNone;
|
||||
}
|
||||
}
|
||||
|
||||
function getDefaultStyleValue(style) {
|
||||
if (style == 'position') {
|
||||
return 'relative';
|
||||
@@ -466,6 +477,7 @@ function getYogaStyle(node) {
|
||||
'height',
|
||||
'min-height',
|
||||
'max-height',
|
||||
'display',
|
||||
].reduce(function(map, key) {
|
||||
map[key] = node.style[key] || getComputedStyle(node, null).getPropertyValue(key);
|
||||
return map;
|
||||
|
Reference in New Issue
Block a user