Open History to see the last commit
1diff --git a/Common/cpp/reanimated/LayoutAnimations/LayoutAnimationsProxyCommon.h b/Common/cpp/reanimated/LayoutAnimations/LayoutAnimationsProxyCommon.h
2index 20d042b00e4655a6647eff1a9a0890fae7e45175..fd08d36fd6c1f79adcfa0dc675420e42a9815d25 100644
3--- a/Common/cpp/reanimated/LayoutAnimations/LayoutAnimationsProxyCommon.h
4+++ b/Common/cpp/reanimated/LayoutAnimations/LayoutAnimationsProxyCommon.h
5@@ -22,6 +22,7 @@ struct LayoutAnimation {
6 Tag parentTag;
7 std::optional<double> opacity;
8 bool isViewAlreadyMounted = false;
9+ bool isExitingWhenSettled = false;
10 int count = 1;
11 LayoutAnimation &operator=(const LayoutAnimation &other) = default;
13diff --git a/Common/cpp/reanimated/LayoutAnimations/LayoutAnimationsProxy_Experimental.cpp b/Common/cpp/reanimated/LayoutAnimations/LayoutAnimationsProxy_Experimental.cpp
14index 0f08622518910486bb724b664e0a5dd692470b18..9f71dbc301e77656ab0c5dc453ade03eea7649f8 100644
15--- a/Common/cpp/reanimated/LayoutAnimations/LayoutAnimationsProxy_Experimental.cpp
16+++ b/Common/cpp/reanimated/LayoutAnimations/LayoutAnimationsProxy_Experimental.cpp
17@@ -353,6 +353,7 @@ std::optional<SurfaceId> LayoutAnimationsProxy_Experimental::endLayoutAnimation(
18 if (--layoutAnimation.count > 0) {
19 return {};
20 }
21+ layoutAnimation.isExitingWhenSettled = shouldRemove;
22 maybeSettledAnimationTags_.insert(tag);
23 auto surfaceId = layoutAnimation.finalView.surfaceId;
25@@ -478,7 +479,8 @@ void LayoutAnimationsProxy_Experimental::addOngoingAnimations(SurfaceId surfaceI
27 const auto layoutAnimationIt = layoutAnimations_.find(tag);
29- if (layoutAnimationIt == layoutAnimations_.end() || layoutAnimationIt->second.isSettled()) {
30+ if (layoutAnimationIt == layoutAnimations_.end() ||
31+ (layoutAnimationIt->second.isSettled() && layoutAnimationIt->second.isExitingWhenSettled)) {
32 continue;
33 }
35@@ -635,6 +637,8 @@ void LayoutAnimationsProxy_Experimental::maybeCancelAnimation(const int tag) con
36 }
37 if (layoutAnimationIt->second.isSettled()) {
38 // Already settled - cleanupAnimations will erase it together with its updateMap entry.
39+ // Do not flush a pending Update after the caller queues this view for removal.
40+ layoutAnimationIt->second.isExitingWhenSettled = true;
41 return;
42 }
43 layoutAnimations_.erase(layoutAnimationIt);
44diff --git a/Common/cpp/reanimated/LayoutAnimations/LayoutAnimationsProxy_Legacy.cpp b/Common/cpp/reanimated/LayoutAnimations/LayoutAnimationsProxy_Legacy.cpp
45index f9711f4eb6185ea99e08280ff90edd45e4152e12..ca812666ca54ec55d9d4409910b21ae97c721f2f 100644
46--- a/Common/cpp/reanimated/LayoutAnimations/LayoutAnimationsProxy_Legacy.cpp
47+++ b/Common/cpp/reanimated/LayoutAnimations/LayoutAnimationsProxy_Legacy.cpp
48@@ -228,6 +228,7 @@ std::optional<SurfaceId> LayoutAnimationsProxy_Legacy::endLayoutAnimation(int ta
49 if (--layoutAnimation.count > 0) {
50 return {};
51 }
52+ layoutAnimation.isExitingWhenSettled = shouldRemove;
53 maybeSettledAnimationTags_.insert(tag);
54 auto surfaceId = layoutAnimation.finalView.surfaceId;
56@@ -531,12 +532,7 @@ void LayoutAnimationsProxy_Legacy::addOngoingAnimations(SurfaceId surfaceId, Sha
57 auto layoutAnimationIt = layoutAnimations_.find(tag);
59 if (layoutAnimationIt == layoutAnimations_.end() ||
60- // A settled animation is normally cleaned up without applying further
61- // updates. The exception is a flaky entering animation whose opacity was
62- // never restored (the view wasn't mounted in time) - we still need to
63- // apply that pending opacity, otherwise the view stays invisible. Only
64- // entering animations carry an opacity value.
65- (layoutAnimationIt->second.isSettled() && !layoutAnimationIt->second.opacity.has_value())) {
66+ (layoutAnimationIt->second.isSettled() && layoutAnimationIt->second.isExitingWhenSettled)) {
67 continue;
68 }