Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 9 additions & 26 deletions packages/react-reconciler/src/ReactFiberCommitViewTransitions.js
Original file line number Diff line number Diff line change
Expand Up @@ -514,37 +514,20 @@ function restorePairedViewTransitions(parent: Fiber): void {
}
}

export function restoreEnterViewTransitions(placement: Fiber): void {
if (placement.tag === ViewTransitionComponent) {
const instance: ViewTransitionState = placement.stateNode;
instance.paired = null;
restoreViewTransitionOnHostInstances(placement.child, false);
restorePairedViewTransitions(placement);
} else if ((placement.subtreeFlags & ViewTransitionStatic) !== NoFlags) {
let child = placement.child;
while (child !== null) {
restoreEnterViewTransitions(child);
child = child.sibling;
}
} else {
restorePairedViewTransitions(placement);
}
}

export function restoreExitViewTransitions(deletion: Fiber): void {
if (deletion.tag === ViewTransitionComponent) {
const instance: ViewTransitionState = deletion.stateNode;
export function restoreEnterOrExitViewTransitions(fiber: Fiber): void {
if (fiber.tag === ViewTransitionComponent) {
const instance: ViewTransitionState = fiber.stateNode;
instance.paired = null;
restoreViewTransitionOnHostInstances(deletion.child, false);
restorePairedViewTransitions(deletion);
} else if ((deletion.subtreeFlags & ViewTransitionStatic) !== NoFlags) {
let child = deletion.child;
restoreViewTransitionOnHostInstances(fiber.child, false);
restorePairedViewTransitions(fiber);
} else if ((fiber.subtreeFlags & ViewTransitionStatic) !== NoFlags) {
let child = fiber.child;
while (child !== null) {
restoreExitViewTransitions(child);
restoreEnterOrExitViewTransitions(child);
child = child.sibling;
}
} else {
restorePairedViewTransitions(deletion);
restorePairedViewTransitions(fiber);
}
}

Expand Down
9 changes: 4 additions & 5 deletions packages/react-reconciler/src/ReactFiberCommitWork.js
Original file line number Diff line number Diff line change
Expand Up @@ -241,8 +241,7 @@ import {
commitExitViewTransitions,
commitBeforeUpdateViewTransition,
commitNestedViewTransitions,
restoreEnterViewTransitions,
restoreExitViewTransitions,
restoreEnterOrExitViewTransitions,
restoreUpdateViewTransition,
restoreNestedViewTransitions,
measureUpdateViewTransition,
Expand Down Expand Up @@ -3175,7 +3174,7 @@ function commitPassiveMountOnFiber(
// This was a new mount. This means we could've triggered an enter animation on
// the content. Restore the view transitions if there were any assigned in the
// snapshot phase.
restoreEnterViewTransitions(finishedWork);
restoreEnterOrExitViewTransitions(finishedWork);
}

// When updating this function, also update reconnectPassiveEffects, which does
Expand Down Expand Up @@ -3476,7 +3475,7 @@ function commitPassiveMountOnFiber(
// Content is now hidden but wasn't before. This means we could've
// triggered an exit animation on the content. Restore the view
// transitions if there were any assigned in the snapshot phase.
restoreExitViewTransitions(current);
restoreEnterOrExitViewTransitions(current);
}
if (instance._visibility & OffscreenPassiveEffectsConnected) {
// The effects are currently connected. Update them.
Expand Down Expand Up @@ -3523,7 +3522,7 @@ function commitPassiveMountOnFiber(
// Content is now visible but wasn't before. This means we could've
// triggered an enter animation on the content. Restore the view
// transitions if there were any assigned in the snapshot phase.
restoreEnterViewTransitions(finishedWork);
restoreEnterOrExitViewTransitions(finishedWork);
}
if (instance._visibility & OffscreenPassiveEffectsConnected) {
// The effects are currently connected. Update them.
Expand Down
Loading