Skip to content

Commit 4525f5c

Browse files
committed
fix(mobile): rebase retained entering-frame props
1 parent dc133ec commit 4525f5c

2 files changed

Lines changed: 57 additions & 11 deletions

File tree

‎patches/[email protected]‎

Lines changed: 51 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -111,9 +111,45 @@ index c0825bb47a6fac02331138b5e0a0e5bbb52df0fa..1658cd1286d1087dec1dff84234f6251
111111
}
112112

113113
diff --git a/Common/cpp/reanimated/LayoutAnimations/LayoutAnimationsProxyCommon.cpp b/Common/cpp/reanimated/LayoutAnimations/LayoutAnimationsProxyCommon.cpp
114+
index 0742d063666ac5579232b2f53e4117f427b7177d..3df48c377c4ad9c483d3cc6e5f4d867afd8c4032 100644
114115
--- a/Common/cpp/reanimated/LayoutAnimations/LayoutAnimationsProxyCommon.cpp
115116
+++ b/Common/cpp/reanimated/LayoutAnimations/LayoutAnimationsProxyCommon.cpp
116-
@@ -265,7 +265,8 @@ ShadowView LayoutAnimationsProxyCommon::materializeLayoutAnimation(
117+
@@ -85,6 +85,11 @@ std::optional<SurfaceId> LayoutAnimationsProxyCommon::progressLayoutAnimation(
118+
}
119+
120+
auto rawProps = std::make_shared<RawProps>(uiRuntime_, jsi::Value(uiRuntime_, newStyle));
121+
+ // Rebase only the entering frame's own props, not its React base or fallback opacity.
122+
+ folly::dynamic enteringProps = nullptr;
123+
+ if (layoutAnimation.type == LayoutAnimationType::ENTERING) {
124+
+ enteringProps = (folly::dynamic)*rawProps;
125+
+ }
126+
if (layoutAnimation.opacity) {
127+
auto props = (folly::dynamic)*rawProps;
128+
props["opacity"] = *layoutAnimation.opacity;
129+
@@ -97,7 +102,7 @@ std::optional<SurfaceId> LayoutAnimationsProxyCommon::progressLayoutAnimation(
130+
#endif
131+
auto newProps = componentDescriptorRegistry_->at(layoutAnimation.finalView.componentHandle)
132+
.cloneProps(propsParserContext, layoutAnimation.finalView.props, std::move(*rawProps));
133+
- updateMap_.insert_or_assign(tag, UpdateValues{newProps, Frame(uiRuntime_, newStyle)});
134+
+ updateMap_.insert_or_assign(tag, UpdateValues{newProps, Frame(uiRuntime_, newStyle), std::move(enteringProps)});
135+
136+
return surfaceId_;
137+
}
138+
@@ -251,6 +256,13 @@ void LayoutAnimationsProxyCommon::applySynchronousPropsToLayoutAnimation(const T
139+
auto pendingView = animation->finalView;
140+
pendingView.props = it->second.newProps;
141+
it->second.newProps = mergeSynchronousProps(pendingView, props);
142+
+ if (!it->second.enteringProps.isNull()) {
143+
+ for (const auto &[key, value] : props.items()) {
144+
+ if (it->second.enteringProps.count(key) > 0) {
145+
+ it->second.enteringProps[key] = value;
146+
+ }
147+
+ }
148+
+ }
149+
}
150+
}
151+
152+
@@ -265,7 +277,8 @@ ShadowView LayoutAnimationsProxyCommon::materializeLayoutAnimation(
117153
auto currentView = before;
118154
const auto activeAnimationIt = layoutAnimations_.find(tag);
119155
if (type == LayoutAnimationType::ENTERING) {
@@ -123,15 +159,17 @@ diff --git a/Common/cpp/reanimated/LayoutAnimations/LayoutAnimationsProxyCommon.
123159
} else if (activeAnimationIt != layoutAnimations_.end()) {
124160
currentView = activeAnimationIt->second.currentView;
125161
} else if (const auto completedAnimationIt = completedAnimations_.find(tag);
126-
@@ -546,5 +547,16 @@ bool LayoutAnimationsProxyCommon::updateEnteringAnimationTarget(const Tag tag, const ShadowView &finalView) const {
162+
@@ -546,6 +559,19 @@ bool LayoutAnimationsProxyCommon::updateEnteringAnimationTarget(const Tag tag, c
127163
}
128164
return true;
129165
}
130166
+ if (const auto completedAnimationIt = completedAnimations_.find(tag);
131167
+ completedAnimationIt != completedAnimations_.end() && !completedAnimationIt->second.shouldRemove &&
132168
+ completedAnimationIt->second.animation.type == LayoutAnimationType::ENTERING && updateMap_.contains(tag)) {
133-
+ // Retargeting must preserve the queued final frame until it reaches the native view.
169+
+ // Preserve the queued animation values without replaying props from the old React target.
134170
+ auto &animation = completedAnimationIt->second.animation;
171+
+ auto &updateValues = updateMap_.at(tag);
172+
+ updateValues.newProps = mergeSynchronousProps(finalView, updateValues.enteringProps);
135173
+ animation.finalView = finalView;
136174
+ if (animation.opacity) {
137175
+ animation.opacity = getViewProps(finalView).opacity;
@@ -142,10 +180,18 @@ diff --git a/Common/cpp/reanimated/LayoutAnimations/LayoutAnimationsProxyCommon.
142180
}
143181

144182
diff --git a/Common/cpp/reanimated/LayoutAnimations/LayoutAnimationsUtils.h b/Common/cpp/reanimated/LayoutAnimations/LayoutAnimationsUtils.h
145-
index 675b1b7d890971d0c43522f59106f1cf20b0fe1a..dea79ba4806e8f1ac31a11c7fa045298b54d6305 100644
183+
index 675b1b7d890971d0c43522f59106f1cf20b0fe1a..af17cfe82e4d47969ddee02fa343e3c31b856e02 100644
146184
--- a/Common/cpp/reanimated/LayoutAnimations/LayoutAnimationsUtils.h
147185
+++ b/Common/cpp/reanimated/LayoutAnimations/LayoutAnimationsUtils.h
148-
@@ -247,7 +247,9 @@ static inline bool isRNSScreenOrStack(const std::shared_ptr<LightNode> &node) {
186+
@@ -44,6 +44,7 @@ struct Frame {
187+
struct UpdateValues {
188+
Props::Shared newProps;
189+
Frame frame;
190+
+ folly::dynamic enteringProps = nullptr;
191+
};
192+
193+
struct Snapshot {
194+
@@ -247,7 +248,9 @@ static inline bool isRNSScreenOrStack(const std::shared_ptr<LightNode> &node) {
149195
const auto componentName = node->current.componentName;
150196
react_native_assert(componentName && "Component name is nullptr");
151197
return !std::strcmp(componentName, "RNSScreenStack") || !std::strcmp(componentName, "RNSScreen") ||

‎pnpm-lock.yaml‎

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)