Skip to content

Commit aeed939

Browse files
coadofabriziocucci
authored andcommitted
Add support for backfaceVisibility and add flex to AnimatedPropsBuilder (#55154)
Summary: Pull Request resolved: #55154 ## Summary: Add support for the `backfaceVisibility` and add missing `flex` style to the `AnimatedPropsBuilder`. ## Changelog: [General][Added] - added support for `backfaceVisibility` prop and added missing `flex` style to the `AnimatedPropsBuilder`. Reviewed By: zeyap Differential Revision: D90671092 fbshipit-source-id: d1731d1811756a665b830d3cd2d88be405112632
1 parent c802cb6 commit aeed939

4 files changed

Lines changed: 43 additions & 3 deletions

File tree

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

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -462,9 +462,9 @@ void packBoxShadow(folly::dynamic& dyn, const AnimatedPropBase& animatedProp) {
462462
void packMixBlendMode(
463463
folly::dynamic& dyn,
464464
const AnimatedPropBase& animatedProp) {
465-
const auto& blendMode = get<BlendMode>(animatedProp);
465+
const auto& mixBlendMode = get<BlendMode>(animatedProp);
466466
std::string blendModeStr;
467-
switch (blendMode) {
467+
switch (mixBlendMode) {
468468
case BlendMode::Normal:
469469
blendModeStr = "normal";
470470
break;
@@ -519,6 +519,25 @@ void packMixBlendMode(
519519
dyn.insert("mixBlendMode", blendModeStr);
520520
}
521521

522+
void packBackfaceVisibility(
523+
folly::dynamic& dyn,
524+
const AnimatedPropBase& animatedProp) {
525+
const auto& backfaceVisibility = get<BackfaceVisibility>(animatedProp);
526+
std::string visibilityStr;
527+
switch (backfaceVisibility) {
528+
case BackfaceVisibility::Auto:
529+
visibilityStr = "auto";
530+
break;
531+
case BackfaceVisibility::Visible:
532+
visibilityStr = "visible";
533+
break;
534+
case BackfaceVisibility::Hidden:
535+
visibilityStr = "hidden";
536+
break;
537+
}
538+
dyn.insert("backfaceVisibility", visibilityStr);
539+
}
540+
522541
void packAnimatedProp(
523542
folly::dynamic& dyn,
524543
const std::unique_ptr<AnimatedPropBase>& animatedProp) {
@@ -607,6 +626,10 @@ void packAnimatedProp(
607626
packMixBlendMode(dyn, *animatedProp);
608627
break;
609628

629+
case BACKFACE_VISIBILITY:
630+
packBackfaceVisibility(dyn, *animatedProp);
631+
break;
632+
610633
case WIDTH:
611634
case HEIGHT:
612635
case FLEX:

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,8 @@ enum PropName {
6262
ISOLATION,
6363
CURSOR,
6464
BOX_SHADOW,
65-
MIX_BLEND_MODE
65+
MIX_BLEND_MODE,
66+
BACKFACE_VISIBILITY
6667
};
6768

6869
struct AnimatedPropBase {
@@ -410,6 +411,10 @@ inline void cloneProp(BaseViewProps &viewProps, const AnimatedPropBase &animated
410411
viewProps.mixBlendMode = get<BlendMode>(animatedProp);
411412
break;
412413

414+
case BACKFACE_VISIBILITY:
415+
viewProps.backfaceVisibility = get<BackfaceVisibility>(animatedProp);
416+
break;
417+
413418
default:
414419
break;
415420
}

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,10 @@ struct AnimatedPropsBuilder {
5252
{
5353
props.push_back(std::make_unique<AnimatedProp<CascadedRectangleEdges<yoga::StyleLength>>>(POSITION, value));
5454
}
55+
void setFlex(yoga::FloatOptional value)
56+
{
57+
props.push_back(std::make_unique<AnimatedProp<yoga::FloatOptional>>(FLEX, value));
58+
}
5559
void setTransform(Transform &t)
5660
{
5761
props.push_back(std::make_unique<AnimatedProp<Transform>>(TRANSFORM, std::move(t)));
@@ -212,6 +216,10 @@ struct AnimatedPropsBuilder {
212216
{
213217
props.push_back(std::make_unique<AnimatedProp<BlendMode>>(MIX_BLEND_MODE, value));
214218
}
219+
void setBackfaceVisibility(BackfaceVisibility value)
220+
{
221+
props.push_back(std::make_unique<AnimatedProp<BackfaceVisibility>>(BACKFACE_VISIBILITY, value));
222+
}
215223
void storeDynamic(folly::dynamic &d)
216224
{
217225
rawProps = std::make_unique<RawProps>(std::move(d));

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,10 @@ inline void updateProp(const PropName propName, BaseViewProps &viewProps, const
284284
case MIX_BLEND_MODE:
285285
viewProps.mixBlendMode = snapshot.props.mixBlendMode;
286286
break;
287+
288+
case BACKFACE_VISIBILITY:
289+
viewProps.backfaceVisibility = snapshot.props.backfaceVisibility;
290+
break;
287291
}
288292
}
289293

0 commit comments

Comments
 (0)