mirror of
https://github.com/zebrajr/react.git
synced 2025-12-06 12:20:20 +01:00
Merge restoreEnterViewTransitions and restoreExitViewTransitions (#32585)
This is the exact same code in both cases. It's just general clean up. By unifying them it becomes less confusing to reuse these helpers in the Apply Gesture path where the naming is reversed.
This commit is contained in:
parent
5398b71158
commit
1b6e3dd985
|
|
@ -514,37 +514,20 @@ function restorePairedViewTransitions(parent: Fiber): void {
|
|||
}
|
||||
}
|
||||
|
||||
export function restoreEnterViewTransitions(placement: Fiber): void {
|
||||
if (placement.tag === ViewTransitionComponent) {
|
||||
const instance: ViewTransitionState = placement.stateNode;
|
||||
export function restoreEnterOrExitViewTransitions(fiber: Fiber): void {
|
||||
if (fiber.tag === ViewTransitionComponent) {
|
||||
const instance: ViewTransitionState = fiber.stateNode;
|
||||
instance.paired = null;
|
||||
restoreViewTransitionOnHostInstances(placement.child, false);
|
||||
restorePairedViewTransitions(placement);
|
||||
} else if ((placement.subtreeFlags & ViewTransitionStatic) !== NoFlags) {
|
||||
let child = placement.child;
|
||||
restoreViewTransitionOnHostInstances(fiber.child, false);
|
||||
restorePairedViewTransitions(fiber);
|
||||
} else if ((fiber.subtreeFlags & ViewTransitionStatic) !== NoFlags) {
|
||||
let child = fiber.child;
|
||||
while (child !== null) {
|
||||
restoreEnterViewTransitions(child);
|
||||
restoreEnterOrExitViewTransitions(child);
|
||||
child = child.sibling;
|
||||
}
|
||||
} else {
|
||||
restorePairedViewTransitions(placement);
|
||||
}
|
||||
}
|
||||
|
||||
export function restoreExitViewTransitions(deletion: Fiber): void {
|
||||
if (deletion.tag === ViewTransitionComponent) {
|
||||
const instance: ViewTransitionState = deletion.stateNode;
|
||||
instance.paired = null;
|
||||
restoreViewTransitionOnHostInstances(deletion.child, false);
|
||||
restorePairedViewTransitions(deletion);
|
||||
} else if ((deletion.subtreeFlags & ViewTransitionStatic) !== NoFlags) {
|
||||
let child = deletion.child;
|
||||
while (child !== null) {
|
||||
restoreExitViewTransitions(child);
|
||||
child = child.sibling;
|
||||
}
|
||||
} else {
|
||||
restorePairedViewTransitions(deletion);
|
||||
restorePairedViewTransitions(fiber);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -246,8 +246,7 @@ import {
|
|||
commitExitViewTransitions,
|
||||
commitBeforeUpdateViewTransition,
|
||||
commitNestedViewTransitions,
|
||||
restoreEnterViewTransitions,
|
||||
restoreExitViewTransitions,
|
||||
restoreEnterOrExitViewTransitions,
|
||||
restoreUpdateViewTransition,
|
||||
restoreNestedViewTransitions,
|
||||
measureUpdateViewTransition,
|
||||
|
|
@ -3228,7 +3227,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
|
||||
|
|
@ -3529,7 +3528,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.
|
||||
|
|
@ -3576,7 +3575,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.
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user