From a30e39cd1b16b992f8cc28386e1616da46dbd9b7 Mon Sep 17 00:00:00 2001 From: Krzysztof Piaskowy Date: Tue, 4 Jan 2022 12:53:52 +0100 Subject: [PATCH 1/2] Changed default ViewState --- ios/LayoutReanimation/REAAnimationsManager.h | 2 +- ios/LayoutReanimation/REAAnimationsManager.m | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/ios/LayoutReanimation/REAAnimationsManager.h b/ios/LayoutReanimation/REAAnimationsManager.h index 3156e48e2fe..1fb2734e8a1 100644 --- a/ios/LayoutReanimation/REAAnimationsManager.h +++ b/ios/LayoutReanimation/REAAnimationsManager.h @@ -5,10 +5,10 @@ NS_ASSUME_NONNULL_BEGIN typedef NS_ENUM(NSInteger, ViewState) { + Inactive, Appearing, Disappearing, Layout, - Inactive, ToRemove, }; diff --git a/ios/LayoutReanimation/REAAnimationsManager.m b/ios/LayoutReanimation/REAAnimationsManager.m index 055222bd6ef..962a3200241 100644 --- a/ios/LayoutReanimation/REAAnimationsManager.m +++ b/ios/LayoutReanimation/REAAnimationsManager.m @@ -150,6 +150,10 @@ - (void)removeLeftovers NSMutableSet *roots = [NSMutableSet new]; for (NSNumber *viewTag in _toRemove) { UIView *view = _viewForTag[viewTag]; + if (view == nil) { + view = [_reaUiManager viewForReactTag:viewTag]; + _viewForTag[viewTag] = view; + } [self findRoot:view roots:roots]; } for (NSNumber *viewTag in roots) { From 164a857be625059be0115ed5bb11d118760a9f05 Mon Sep 17 00:00:00 2001 From: Krzysztof Piaskowy Date: Tue, 4 Jan 2022 15:12:36 +0100 Subject: [PATCH 2/2] Fix for Android --- .../layoutReanimation/AnimationsManager.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/android/src/main/java/com/swmansion/reanimated/layoutReanimation/AnimationsManager.java b/android/src/main/java/com/swmansion/reanimated/layoutReanimation/AnimationsManager.java index b72de2575ec..211885c4ea3 100644 --- a/android/src/main/java/com/swmansion/reanimated/layoutReanimation/AnimationsManager.java +++ b/android/src/main/java/com/swmansion/reanimated/layoutReanimation/AnimationsManager.java @@ -61,10 +61,10 @@ public void setScheduler(Scheduler scheduler) { } public enum ViewState { + Inactive, Appearing, Disappearing, Layout, - Inactive, ToRemove; } @@ -107,11 +107,11 @@ public void onViewRemoval(View view, ViewGroup parent, Snapshot before, Runnable HashMap currentValues = before.toCurrentMap(); ViewState state = mStates.get(view.getId()); - if (state == null || state == ViewState.Disappearing || state == ViewState.ToRemove) { + if (state == ViewState.Disappearing || state == ViewState.ToRemove) { return; } mCallbacks.put(tag, callback); - if (state == ViewState.Inactive) { + if (state == ViewState.Inactive || state == null) { if (currentValues != null) { mStates.put(view.getId(), ViewState.ToRemove); mToRemove.add(view.getId()); @@ -232,6 +232,10 @@ private void removeLeftovers() { // go through ready to remove from bottom to top for (int tag : mToRemove) { View view = mViewForTag.get(tag); + if (view == null) { + view = mUIManager.resolveView(tag); + mViewForTag.put(tag, view); + } findRoot(view, roots); } for (int tag : roots) {