Skip to content

Commit

Permalink
[Shared Element Transition] Fix: view disappeared after layout animat…
Browse files Browse the repository at this point in the history
…ion (software-mansion#4026)

## Summary

I added a check to prevent adding already existing views to the shared
transition registry. The issue only occurred when the view had a layout
animation, as the registry is cleared after the animation ends.
Afterwards, views from the registry were removed from their parent view.
In the case of a shared transition, the parent screen is a custom
temporary transition container, but in the case of a regular layout
animation, the super view is the original parent. As a result, the view
disappeared.
  • Loading branch information
piaskowyk authored and fluiddot committed Jun 5, 2023
1 parent ccf9c38 commit bff033b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion ios/LayoutReanimation/REAAnimationsManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -521,7 +521,7 @@ - (void)viewDidMount:(UIView *)view withBeforeSnapshot:(nonnull REASnapshot *)be
[self setNewProps:before.values forView:view];
}

if (_hasAnimationForTag(viewTag, @"sharedElementTransition")) {
if (_hasAnimationForTag(viewTag, @"sharedElementTransition") && [type isEqual:@"entering"]) {
[_sharedTransitionManager notifyAboutNewView:view];
}
}
Expand Down
6 changes: 4 additions & 2 deletions ios/LayoutReanimation/REASharedTransitionManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,10 @@ - (void)viewsDidLayout

- (void)configureAsyncSharedTransitionForViews:(NSArray<UIView *> *)views
{
NSArray *sharedViews = [self sortViewsByTags:views];
_sharedElements = [self getSharedElementForCurrentTransition:sharedViews withNewElements:YES];
if ([views count] > 0) {
NSArray *sharedViews = [self sortViewsByTags:views];
_sharedElements = [self getSharedElementForCurrentTransition:sharedViews withNewElements:YES];
}
}

- (BOOL)configureAndStartSharedTransitionForViews:(NSArray<UIView *> *)views
Expand Down

0 comments on commit bff033b

Please sign in to comment.