Skip to content

Commit 82d1c33

Browse files
coadofacebook-github-bot
authored andcommitted
Add support for other flex props to the Animation Backend (facebook#54946)
Summary: ## Summary: Adds support for `overflow`, `position`, `zIndex`, and `direction` layout props to be passed as `AnimatedProp` to the animation backend. The `PropName` enum is changed to the class enum because the `OVERFLOW` keyword is already defined in `math.h` when building with `XCode`. ## Changelog: [General][Added] - Added support for `overflow`, `position`, `zIndex`, and `direction` props to the AnimationBackend. Reviewed By: zeyap Differential Revision: D89543930
1 parent 4f95f1f commit 82d1c33

File tree

5 files changed

+61
-11
lines changed

5 files changed

+61
-11
lines changed

packages/react-native/ReactCommon/react/renderer/animationbackend/AnimatedPropSerializer.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,10 @@ void packAnimatedProp(
283283
case MAX_WIDTH:
284284
case MIN_HEIGHT:
285285
case MIN_WIDTH:
286+
case STYLE_OVERFLOW:
287+
case POSITION_TYPE:
288+
case Z_INDEX:
289+
case DIRECTION:
286290
throw std::runtime_error("Tried to synchronously update layout props");
287291
}
288292
}

packages/react-native/ReactCommon/react/renderer/animationbackend/AnimatedProps.h

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,11 @@ enum PropName {
5151
MAX_HEIGHT,
5252
MAX_WIDTH,
5353
MIN_HEIGHT,
54-
MIN_WIDTH
54+
MIN_WIDTH,
55+
STYLE_OVERFLOW,
56+
POSITION_TYPE,
57+
Z_INDEX,
58+
DIRECTION,
5559
};
5660

5761
struct AnimatedPropBase {
@@ -355,7 +359,20 @@ inline void cloneProp(BaseViewProps &viewProps, const AnimatedPropBase &animated
355359
viewProps.yogaStyle.setMinDimension(yoga::Dimension::Width, get<yoga::Style::SizeLength>(animatedProp));
356360
break;
357361

358-
default:
362+
case STYLE_OVERFLOW:
363+
viewProps.yogaStyle.setOverflow(get<yoga::Overflow>(animatedProp));
364+
break;
365+
366+
case POSITION_TYPE:
367+
viewProps.yogaStyle.setPositionType(get<yoga::PositionType>(animatedProp));
368+
break;
369+
370+
case Z_INDEX:
371+
viewProps.zIndex = get<std::optional<int>>(animatedProp);
372+
break;
373+
374+
case DIRECTION:
375+
viewProps.yogaStyle.setDirection(get<yoga::Direction>(animatedProp));
359376
break;
360377
}
361378
}

packages/react-native/ReactCommon/react/renderer/animationbackend/AnimatedPropsBuilder.h

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,22 @@ struct AnimatedPropsBuilder {
168168
{
169169
props.push_back(std::make_unique<AnimatedProp<yoga::Style::SizeLength>>(MIN_WIDTH, value));
170170
}
171+
void setOverflow(yoga::Overflow value)
172+
{
173+
props.push_back(std::make_unique<AnimatedProp<yoga::Overflow>>(STYLE_OVERFLOW, value));
174+
}
175+
void setPositionType(yoga::PositionType value)
176+
{
177+
props.push_back(std::make_unique<AnimatedProp<yoga::PositionType>>(POSITION_TYPE, value));
178+
}
179+
void setZIndex(std::optional<int> value)
180+
{
181+
props.push_back(std::make_unique<AnimatedProp<std::optional<int>>>(Z_INDEX, value));
182+
}
183+
void setDirection(yoga::Direction value)
184+
{
185+
props.push_back(std::make_unique<AnimatedProp<yoga::Direction>>(DIRECTION, value));
186+
}
171187
void storeDynamic(folly::dynamic &d)
172188
{
173189
rawProps = std::make_unique<RawProps>(std::move(d));

packages/react-native/ReactCommon/react/renderer/animationbackend/AnimatedPropsRegistry.h

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,22 @@ inline void updateProp(const PropName propName, BaseViewProps &viewProps, const
239239
viewProps.yogaStyle.setMinDimension(
240240
yoga::Dimension::Width, snapshot.props.yogaStyle.minDimension(yoga::Dimension::Width));
241241
break;
242+
243+
case STYLE_OVERFLOW:
244+
viewProps.yogaStyle.setOverflow(snapshot.props.yogaStyle.overflow());
245+
break;
246+
247+
case POSITION_TYPE:
248+
viewProps.yogaStyle.setPositionType(snapshot.props.yogaStyle.positionType());
249+
break;
250+
251+
case Z_INDEX:
252+
viewProps.zIndex = snapshot.props.zIndex;
253+
break;
254+
255+
case DIRECTION:
256+
viewProps.yogaStyle.setDirection(snapshot.props.yogaStyle.direction());
257+
break;
242258
}
243259
}
244260

packages/react-native/ReactCommon/react/renderer/animationbackend/AnimationBackend.cpp

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,12 @@
1616
namespace facebook::react {
1717

1818
static const auto layoutProps = std::set<PropName>{
19-
PropName::WIDTH, PropName::HEIGHT, PropName::FLEX,
20-
PropName::MARGIN, PropName::PADDING, PropName::POSITION,
21-
PropName::BORDER_WIDTH, PropName::ALIGN_CONTENT, PropName::ALIGN_ITEMS,
22-
PropName::ALIGN_SELF, PropName::ASPECT_RATIO, PropName::BOX_SIZING,
23-
PropName::DISPLAY, PropName::FLEX_BASIS, PropName::FLEX_DIRECTION,
24-
PropName::ROW_GAP, PropName::COLUMN_GAP, PropName::FLEX_GROW,
25-
PropName::FLEX_SHRINK, PropName::FLEX_WRAP, PropName::JUSTIFY_CONTENT,
26-
PropName::MAX_HEIGHT, PropName::MAX_WIDTH, PropName::MIN_HEIGHT,
27-
PropName::MIN_WIDTH,
19+
WIDTH, HEIGHT, FLEX, MARGIN, PADDING,
20+
POSITION, BORDER_WIDTH, ALIGN_CONTENT, ALIGN_ITEMS, ALIGN_SELF,
21+
ASPECT_RATIO, BOX_SIZING, DISPLAY, FLEX_BASIS, FLEX_DIRECTION,
22+
ROW_GAP, COLUMN_GAP, FLEX_GROW, FLEX_SHRINK, FLEX_WRAP,
23+
JUSTIFY_CONTENT, MAX_HEIGHT, MAX_WIDTH, MIN_HEIGHT, MIN_WIDTH,
24+
STYLE_OVERFLOW, POSITION_TYPE, DIRECTION, Z_INDEX,
2825
};
2926

3027
UIManagerNativeAnimatedDelegateBackendImpl::

0 commit comments

Comments
 (0)