Skip to content

Commit a6e6d07

Browse files
committed
Swap Enter and Exit terminology
Since we're applying transitions in reverse, all "insertions" in the newly finished trees are actually "exits". All "deletions" are "enters".
1 parent f006915 commit a6e6d07

File tree

1 file changed

+25
-26
lines changed

1 file changed

+25
-26
lines changed

packages/react-reconciler/src/ReactFiberApplyGesture.js

Lines changed: 25 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,7 @@ import {
5858
ViewTransitionComponent,
5959
} from './ReactWorkTags';
6060
import {
61-
restoreEnterViewTransitions,
62-
restoreExitViewTransitions,
61+
restoreEnterOrExitViewTransitions,
6362
restoreNestedViewTransitions,
6463
} from './ReactFiberCommitViewTransitions';
6564

@@ -70,11 +69,11 @@ function detectMutationOrInsertClones(finishedWork: Fiber): boolean {
7069
}
7170

7271
const CLONE_UPDATE = 0; // Mutations in this subtree or potentially affected by layout.
73-
const CLONE_ENTER = 1; // Inside a reappearing offscreen before the next ViewTransition or HostComponent.
72+
const CLONE_EXIT = 1; // Inside a reappearing offscreen before the next ViewTransition or HostComponent.
7473
const CLONE_UNHIDE = 2; // Inside a reappearing offscreen before the next HostComponent.
7574
const CLONE_APPEARING_PAIR = 3; // Like UNHIDE but we're already inside the first Host Component only finding pairs.
7675
const CLONE_UNCHANGED = 4; // Nothing in this tree was changed but we're still walking to clone it.
77-
const INSERT_ENTER = 5; // Inside a newly mounted tree before the next ViewTransition or HostComponent.
76+
const INSERT_EXIT = 5; // Inside a newly mounted tree before the next ViewTransition or HostComponent.
7877
const INSERT_APPEND = 6; // Inside a newly mounted tree before the next HostComponent.
7978
const INSERT_APPEARING_PAIR = 7; // Inside a newly mounted tree only finding pairs.
8079
type VisitPhase = 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7;
@@ -105,7 +104,7 @@ function trackDeletedPairViewTransitions(deletion: Fiber): void {
105104
}
106105
}
107106

108-
function trackExitViewTransitions(deletion: Fiber): void {
107+
function trackEnterViewTransitions(deletion: Fiber): void {
109108
if (deletion.tag === ViewTransitionComponent) {
110109
const props: ViewTransitionProps = deletion.memoizedProps;
111110
const name = props.name;
@@ -117,7 +116,7 @@ function trackExitViewTransitions(deletion: Fiber): void {
117116
} else if ((deletion.subtreeFlags & ViewTransitionStatic) !== NoFlags) {
118117
let child = deletion.child;
119118
while (child !== null) {
120-
trackExitViewTransitions(child);
119+
trackEnterViewTransitions(child);
121120
child = child.sibling;
122121
}
123122
} else {
@@ -261,7 +260,7 @@ function recursivelyInsertNewFiber(
261260
// TODO: If this was already cloned by a previous pass we can reuse those clones.
262261
viewTransitionState.clones = null;
263262
let nextPhase;
264-
if (visitPhase === INSERT_ENTER) {
263+
if (visitPhase === INSERT_EXIT) {
265264
// This was an Enter of a ViewTransition. We now move onto inserting the inner
266265
// HostComponents and finding inner pairs.
267266
nextPhase = INSERT_APPEND;
@@ -307,7 +306,7 @@ function recursivelyInsertClonesFromExistingTree(
307306
// We've found any "layout" View Transitions at this point so we can bail.
308307
keepTraversing = false;
309308
break;
310-
case CLONE_ENTER:
309+
case CLONE_EXIT:
311310
case CLONE_UNHIDE:
312311
case CLONE_APPEARING_PAIR:
313312
// If this was an unhide, we need to keep going if there are any named
@@ -345,7 +344,7 @@ function recursivelyInsertClonesFromExistingTree(
345344
parentViewTransition.clones.push(clone);
346345
}
347346
}
348-
if (visitPhase === CLONE_ENTER || visitPhase === CLONE_UNHIDE) {
347+
if (visitPhase === CLONE_EXIT || visitPhase === CLONE_UNHIDE) {
349348
unhideInstance(clone, child.memoizedProps);
350349
}
351350
break;
@@ -360,7 +359,7 @@ function recursivelyInsertClonesFromExistingTree(
360359
}
361360
const clone = cloneMutableTextInstance(textInstance);
362361
appendChild(hostParentClone, clone);
363-
if (visitPhase === CLONE_ENTER || visitPhase === CLONE_UNHIDE) {
362+
if (visitPhase === CLONE_EXIT || visitPhase === CLONE_UNHIDE) {
364363
unhideTextInstance(clone, child.memoizedProps);
365364
}
366365
break;
@@ -393,7 +392,7 @@ function recursivelyInsertClonesFromExistingTree(
393392
// TODO: If this was already cloned by a previous pass we can reuse those clones.
394393
viewTransitionState.clones = null;
395394
let nextPhase;
396-
if (visitPhase === CLONE_ENTER) {
395+
if (visitPhase === CLONE_EXIT) {
397396
// This was an Enter of a ViewTransition. We now move onto unhiding the inner
398397
// HostComponents and finding inner pairs.
399398
nextPhase = CLONE_UNHIDE;
@@ -440,7 +439,7 @@ function recursivelyInsertClones(
440439
if (deletions !== null) {
441440
for (let i = 0; i < deletions.length; i++) {
442441
const childToDelete = deletions[i];
443-
trackExitViewTransitions(childToDelete);
442+
trackEnterViewTransitions(childToDelete);
444443
}
445444
}
446445

@@ -485,7 +484,7 @@ function insertDestinationClonesOfFiber(
485484
finishedWork,
486485
hostParentClone,
487486
parentViewTransition,
488-
INSERT_ENTER,
487+
INSERT_EXIT,
489488
);
490489
return;
491490
}
@@ -578,7 +577,7 @@ function insertDestinationClonesOfFiber(
578577
commitUpdate(clone, type, oldProps, newProps, finishedWork);
579578
}
580579

581-
if (visitPhase === CLONE_ENTER || visitPhase === CLONE_UNHIDE) {
580+
if (visitPhase === CLONE_EXIT || visitPhase === CLONE_UNHIDE) {
582581
recursivelyInsertClones(
583582
finishedWork,
584583
clone,
@@ -615,7 +614,7 @@ function insertDestinationClonesOfFiber(
615614
commitTextUpdate(clone, newText, oldText);
616615
}
617616
appendChild(hostParentClone, clone);
618-
if (visitPhase === CLONE_ENTER || visitPhase === CLONE_UNHIDE) {
617+
if (visitPhase === CLONE_EXIT || visitPhase === CLONE_UNHIDE) {
619618
unhideTextInstance(clone, finishedWork.memoizedProps);
620619
}
621620
break;
@@ -634,7 +633,7 @@ function insertDestinationClonesOfFiber(
634633
let nextPhase;
635634
if (visitPhase === CLONE_UPDATE && (flags & Visibility) !== NoFlags) {
636635
// This is the root of an appear. We need to trigger Enter transitions.
637-
nextPhase = CLONE_ENTER;
636+
nextPhase = CLONE_EXIT;
638637
} else {
639638
nextPhase = visitPhase;
640639
}
@@ -646,7 +645,7 @@ function insertDestinationClonesOfFiber(
646645
);
647646
} else if (current !== null && current.memoizedState === null) {
648647
// Was previously mounted as visible but is now hidden.
649-
trackExitViewTransitions(current);
648+
trackEnterViewTransitions(current);
650649
}
651650
break;
652651
}
@@ -656,7 +655,7 @@ function insertDestinationClonesOfFiber(
656655
// TODO: If this was already cloned by a previous pass we can reuse those clones.
657656
viewTransitionState.clones = null;
658657
let nextPhase;
659-
if (visitPhase === CLONE_ENTER) {
658+
if (visitPhase === CLONE_EXIT) {
660659
// This was an Enter of a ViewTransition. We now move onto unhiding the inner
661660
// HostComponents and finding inner pairs.
662661
nextPhase = CLONE_UNHIDE;
@@ -746,7 +745,7 @@ function applyDeletedPairViewTransitions(deletion: Fiber): void {
746745
}
747746
}
748747

749-
function applyExitViewTransitions(deletion: Fiber): void {
748+
function applyEnterViewTransitions(deletion: Fiber): void {
750749
if (deletion.tag === ViewTransitionComponent) {
751750
const props: ViewTransitionProps = deletion.memoizedProps;
752751
const name = props.name;
@@ -759,7 +758,7 @@ function applyExitViewTransitions(deletion: Fiber): void {
759758
// TODO: Check if this is a hidden Offscreen or a Portal.
760759
let child = deletion.child;
761760
while (child !== null) {
762-
applyExitViewTransitions(child);
761+
applyEnterViewTransitions(child);
763762
child = child.sibling;
764763
}
765764
} else {
@@ -811,7 +810,7 @@ function recursivelyApplyViewTransitions(parentFiber: Fiber) {
811810
if (deletions !== null) {
812811
for (let i = 0; i < deletions.length; i++) {
813812
const childToDelete = deletions[i];
814-
applyExitViewTransitions(childToDelete);
813+
applyEnterViewTransitions(childToDelete);
815814
}
816815
}
817816

@@ -866,7 +865,7 @@ function applyViewTransitionsOnFiber(finishedWork: Fiber) {
866865
measureEnterViewTransitions(finishedWork);
867866
} else if (current !== null && current.memoizedState === null) {
868867
// Was previously mounted as visible but is now hidden.
869-
applyExitViewTransitions(current);
868+
applyEnterViewTransitions(current);
870869
}
871870
}
872871
break;
@@ -903,7 +902,7 @@ function recursivelyRestoreViewTransitions(parentFiber: Fiber) {
903902
if (deletions !== null) {
904903
for (let i = 0; i < deletions.length; i++) {
905904
const childToDelete = deletions[i];
906-
restoreExitViewTransitions(childToDelete);
905+
restoreEnterOrExitViewTransitions(childToDelete);
907906
}
908907
}
909908

@@ -928,7 +927,7 @@ function recursivelyRestoreViewTransitions(parentFiber: Fiber) {
928927
function restoreViewTransitionsOnFiber(finishedWork: Fiber) {
929928
const current = finishedWork.alternate;
930929
if (current === null) {
931-
restoreEnterViewTransitions(finishedWork);
930+
restoreEnterOrExitViewTransitions(finishedWork);
932931
return;
933932
}
934933

@@ -955,10 +954,10 @@ function restoreViewTransitionsOnFiber(finishedWork: Fiber) {
955954
const newState: OffscreenState | null = finishedWork.memoizedState;
956955
const isHidden = newState !== null;
957956
if (!isHidden) {
958-
restoreEnterViewTransitions(finishedWork);
957+
restoreEnterOrExitViewTransitions(finishedWork);
959958
} else if (current !== null && current.memoizedState === null) {
960959
// Was previously mounted as visible but is now hidden.
961-
restoreExitViewTransitions(current);
960+
restoreEnterOrExitViewTransitions(current);
962961
}
963962
}
964963
break;

0 commit comments

Comments
 (0)