62
restoreEnterOrExitViewTransitions,
63
restoreNestedViewTransitions,
64
appearingViewTransitions,
65
+ commitEnterViewTransitions,
66
+ measureNestedViewTransitions,
67
} from './ReactFiberCommitViewTransitions';
68
import {
69
getViewTransitionName,
970
}
971
}
972
971
-function applyDeletedPairViewTransitions(deletion: Fiber): void {
972
- if ((deletion.subtreeFlags & ViewTransitionNamedStatic) === NoFlags) {
973
- // This has no named view transitions in its subtree.
974
- return;
975
- }
976
- let child = deletion.child;
977
- while (child !== null) {
978
- if (child.tag === OffscreenComponent && child.memoizedState === null) {
979
- // This tree was already hidden so we skip it.
980
- } else {
981
- if (
982
- child.tag === ViewTransitionComponent &&
983
- (child.flags & ViewTransitionNamedStatic) !== NoFlags
984
- ) {
985
- const props: ViewTransitionProps = child.memoizedProps;
986
- const name = props.name;
987
- if (name != null && name !== 'auto') {
988
- // TODO: Find a pair
989
- }
990
- }
991
- applyDeletedPairViewTransitions(child);
992
- }
993
- child = child.sibling;
994
- }
995
-}
996
-
997
-function applyEnterViewTransitions(deletion: Fiber): void {
998
- if (deletion.tag === ViewTransitionComponent) {
999
- const props: ViewTransitionProps = deletion.memoizedProps;
1000
- const name = props.name;
1001
- if (name != null && name !== 'auto') {
1002
- // TODO: Find a pair
1003
- }
1004
- // Look for more pairs deeper in the tree.
1005
- applyDeletedPairViewTransitions(deletion);
1006
- } else if ((deletion.subtreeFlags & ViewTransitionStatic) !== NoFlags) {
1007
- // TODO: Check if this is a hidden Offscreen or a Portal.
1008
- let child = deletion.child;
1009
- while (child !== null) {
1010
- applyEnterViewTransitions(child);
1011
- child = child.sibling;
1012
- }
1013
- } else {
1014
- applyDeletedPairViewTransitions(deletion);
1015
- }
1016
-}
1017
-
973
function measureExitViewTransitions(placement: Fiber): void {
974
if (placement.tag === ViewTransitionComponent) {
975
// const state: ViewTransitionState = placement.stateNode;
991
}
992
}
993
1039
-function measureNestedViewTransitions(changedParent: Fiber): void {
1040
- let child = changedParent.child;
1041
- while (child !== null) {
1042
- if (child.tag === ViewTransitionComponent) {
1043
- const current = child.alternate;
1044
- if (current !== null) {
1045
- // const props: ViewTransitionProps = child.memoizedProps;
1046
- // const name = getViewTransitionName(props, child.stateNode);
1047
- // TODO: Measure both the old and new state and see if they're different.
1048
- }
1049
- } else if ((child.subtreeFlags & ViewTransitionStatic) !== NoFlags) {
1050
- // TODO: Check if this is a hidden Offscreen or a Portal.
1051
- measureNestedViewTransitions(child);
1052
- }
1053
- child = child.sibling;
1054
- }
1055
-}
1056
-
994
function measureUpdateViewTransition(
995
current: Fiber,
996
finishedWork: Fiber,
1003
if (deletions !== null) {
1004
for (let i = 0; i < deletions.length; i++) {
1005
const childToDelete = deletions[i];
1069
- applyEnterViewTransitions(childToDelete);
1006
+ commitEnterViewTransitions(childToDelete, true);
1007
}
1008
}
1009
1021
// Nothing has changed in this subtree, but the parent may have still affected
1022
// its size and position. We need to measure the old and new state to see if
1023
// we should animate its size and position.
1087
- measureNestedViewTransitions(parentFiber);
1024
+ measureNestedViewTransitions(parentFiber, true);
1025
}
1026
}
1027
1058
measureExitViewTransitions(finishedWork);
1059
} else if (current !== null && current.memoizedState === null) {
1060
// Was previously mounted as visible but is now hidden.
1124
- applyEnterViewTransitions(current);
1061
+ commitEnterViewTransitions(current, true);
1062
}
1063
}
1064
break;