Default position to NaN

Summary: The position record defaulted to 0, which was wrong. No it defaults to NaN, which is the same as not having a value at all.

Reviewed By: emilsjolander

Differential Revision: D7009783

fbshipit-source-id: 83810da87e983f8d4d3e428f1f5fab0928bce58d
This commit is contained in:
Daniel Büchele
2018-02-16 07:19:57 -08:00
committed by Facebook Github Bot
parent c5371aca64
commit b3436d5eba
3 changed files with 11 additions and 10 deletions

View File

@@ -61,7 +61,12 @@ const r: LayoutRecordT = Record({
padding: PositionRecord(), padding: PositionRecord(),
margin: PositionRecord(), margin: PositionRecord(),
border: PositionRecord(), border: PositionRecord(),
position: PositionRecord(), position: PositionRecord({
left: NaN,
top: NaN,
right: NaN,
bottom: NaN,
}),
positionType: yoga.POSITION_TYPE_RELATIVE, positionType: yoga.POSITION_TYPE_RELATIVE,
flexWrap: yoga.WRAP_NO_WRAP, flexWrap: yoga.WRAP_NO_WRAP,
flexBasis: 'auto', flexBasis: 'auto',

View File

@@ -145,7 +145,7 @@ export default class YogaNode extends Component<Props, State> {
try { try {
root[`set${key[0].toUpperCase()}${key.substr(1)}`]( root[`set${key[0].toUpperCase()}${key.substr(1)}`](
yoga[`EDGE_${direction.toUpperCase()}`], yoga[`EDGE_${direction.toUpperCase()}`],
layoutDefinition[key][direction] || 0, layoutDefinition[key][direction],
); );
} catch (e) {} } catch (e) {}
}); });

View File

@@ -38,17 +38,15 @@ export default class YogaPositionEditor extends Component<Props> {
<div className="YogaPositionEditor"> <div className="YogaPositionEditor">
<Input <Input
type="text" type="text"
value={value.top} value={Number.isNaN(value.top) ? '' : value.top}
disabled={disabled} disabled={disabled}
placeholder="0"
onChange={e => onChange(property, value.set('top', e.target.value))} onChange={e => onChange(property, value.set('top', e.target.value))}
/> />
<div className="YogaPositionEditorRow"> <div className="YogaPositionEditorRow">
<Input <Input
type="text" type="text"
value={value.left} value={Number.isNaN(value.left) ? '' : value.left}
disabled={disabled} disabled={disabled}
placeholder="0"
onChange={e => onChange={e =>
onChange(property, value.set('left', e.target.value)) onChange(property, value.set('left', e.target.value))
} }
@@ -56,9 +54,8 @@ export default class YogaPositionEditor extends Component<Props> {
{property.toUpperCase()} {property.toUpperCase()}
<Input <Input
type="text" type="text"
value={value.right} value={Number.isNaN(value.right) ? '' : value.right}
disabled={disabled} disabled={disabled}
placeholder="0"
onChange={e => onChange={e =>
onChange(property, value.set('right', e.target.value)) onChange(property, value.set('right', e.target.value))
} }
@@ -66,9 +63,8 @@ export default class YogaPositionEditor extends Component<Props> {
</div> </div>
<Input <Input
type="text" type="text"
value={value.bottom} value={Number.isNaN(value.bottom) ? '' : value.bottom}
disabled={disabled} disabled={disabled}
placeholder="0"
onChange={e => onChange={e =>
onChange(property, value.set('bottom', e.target.value)) onChange(property, value.set('bottom', e.target.value))
} }