Skip to content

Commit

Permalink
Fix Layout Animation restart (software-mansion#4095)
Browse files Browse the repository at this point in the history
In software-mansion#4043 I changed the restarting animation logic in
`animationManager.ts`. Accidentally I removed restarting animation for
the rest of the Layout Animations. Fortunately, I found a better way to
handle restart animation for both LA and SET animations types.
  • Loading branch information
piaskowyk authored Feb 24, 2023
1 parent b454698 commit 27d2d8c
Showing 1 changed file with 1 addition and 10 deletions.
11 changes: 1 addition & 10 deletions src/reanimated2/layoutReanimation/animationsManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ function stopObservingProgress(
function createLayoutAnimationManager() {
'worklet';
const enteringAnimationForTag = new Map();
const sharedTransitionForTag = new Map();
const mutableValuesForTag = new Map();

return {
Expand Down Expand Up @@ -64,24 +63,16 @@ function createLayoutAnimationManager() {
value = makeUIMutable(style.initialValues);
mutableValuesForTag.set(tag, value);
} else {
stopObservingProgress(tag, value, false, false);
value._value = style.initialValues;
}

if (sharedTransitionForTag.get(tag)) {
stopObservingProgress(tag, value, true, false);
}

if (type === 'sharedElementTransition') {
sharedTransitionForTag.set(tag, currentAnimation);
}

// @ts-ignore The line below started failing because I added types to the method – don't have time to fix it right now
const animation = withStyleAnimation(currentAnimation);

animation.callback = (finished?: boolean) => {
if (finished) {
enteringAnimationForTag.delete(tag);
sharedTransitionForTag.delete(tag);
mutableValuesForTag.delete(tag);
const shouldRemoveView = type === 'exiting';
stopObservingProgress(tag, value, finished, shouldRemoveView);
Expand Down

0 comments on commit 27d2d8c

Please sign in to comment.