Skip to content

Commit adccef7

Browse files
mystique1729facebook-github-bot
authored andcommitted
Revert D21635473: LayoutAnimations: allow Paragraph props to be interpolated
Differential Revision: D21635473 Original commit changeset: 470f43fd24a6 fbshipit-source-id: 8507b0aaead2c0ebbdd09077db99e5e44da175ab
1 parent a799367 commit adccef7

File tree

3 files changed

+27
-75
lines changed

3 files changed

+27
-75
lines changed

ReactCommon/fabric/components/text/paragraph/ParagraphComponentDescriptor.h

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99

1010
#include "ParagraphShadowNode.h"
1111

12-
#include <react/components/view/ViewPropsInterpolation.h>
1312
#include <react/config/ReactNativeConfig.h>
1413
#include <react/core/ConcreteComponentDescriptor.h>
1514
#include <react/textlayoutmanager/TextLayoutManager.h>
@@ -31,18 +30,6 @@ class ParagraphComponentDescriptor final
3130
textLayoutManager_ = std::make_shared<TextLayoutManager>(contextContainer_);
3231
}
3332

34-
virtual SharedProps interpolateProps(
35-
float animationProgress,
36-
const SharedProps &props,
37-
const SharedProps &newProps) const override {
38-
SharedProps interpolatedPropsShared = cloneProps(newProps, {});
39-
40-
interpolateViewProps(
41-
animationProgress, props, newProps, interpolatedPropsShared);
42-
43-
return interpolatedPropsShared;
44-
};
45-
4633
protected:
4734
void adopt(UnsharedShadowNode shadowNode) const override {
4835
ConcreteComponentDescriptor::adopt(shadowNode);

ReactCommon/fabric/components/view/ViewComponentDescriptor.h

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
#include <react/components/view/ViewShadowNode.h>
1111
#include <react/core/ConcreteComponentDescriptor.h>
1212
#include "ViewProps.h"
13-
#include "ViewPropsInterpolation.h"
1413

1514
namespace facebook {
1615
namespace react {
@@ -25,10 +24,34 @@ class ViewComponentDescriptor
2524
float animationProgress,
2625
const SharedProps &props,
2726
const SharedProps &newProps) const override {
28-
SharedProps interpolatedPropsShared = cloneProps(newProps, {});
27+
ViewProps const *oldViewProps =
28+
dynamic_cast<ViewProps const *>(props.get());
29+
ViewProps const *newViewProps =
30+
dynamic_cast<ViewProps const *>(newProps.get());
2931

30-
interpolateViewProps(
31-
animationProgress, props, newProps, interpolatedPropsShared);
32+
SharedProps interpolatedPropsShared = cloneProps(newProps, {});
33+
ViewProps *interpolatedProps = const_cast<ViewProps *>(
34+
dynamic_cast<ViewProps const *>(interpolatedPropsShared.get()));
35+
36+
interpolatedProps->opacity = oldViewProps->opacity +
37+
(newViewProps->opacity - oldViewProps->opacity) * animationProgress;
38+
39+
interpolatedProps->transform = Transform::Interpolate(
40+
animationProgress, oldViewProps->transform, newViewProps->transform);
41+
42+
// Android uses RawProps, not props, to update props on the platform...
43+
// Since interpolated props don't interpolate at all using RawProps, we need
44+
// to "re-hydrate" raw props after interpolating. This is what actually gets
45+
// sent to the mounting layer. This is a temporary hack, only for platforms
46+
// that use RawProps/folly::dynamic instead of concrete props on the
47+
// mounting layer. Once we can remove this, we should change `rawProps` to
48+
// be const again.
49+
#ifdef ANDROID
50+
interpolatedProps->rawProps["opacity"] = interpolatedProps->opacity;
51+
52+
interpolatedProps->rawProps["transform"] =
53+
(folly::dynamic)interpolatedProps->transform;
54+
#endif
3255

3356
return interpolatedPropsShared;
3457
};

ReactCommon/fabric/components/view/ViewPropsInterpolation.h

Lines changed: 0 additions & 58 deletions
This file was deleted.

0 commit comments

Comments
 (0)