469
// For example, if update="foo" layout="none" and it turns out this was
470
// a layout only change, then the "foo" class will be applied even though
471
// it was not actually an update. Which is a bug.
472
- let className: ?string = getViewTransitionClassName(
472
+ const className: ?string = getViewTransitionClassName(
473
newProps.className,
474
newProps.update,
475
);
476
if (className === 'none') {
477
- className = getViewTransitionClassName(newProps.className, newProps.layout);
478
- if (className === 'none') {
479
- // If both update and layout are both "none" then we don't have to
480
- // apply a name. Since we won't animate this boundary.
481
- return;
482
- }
477
+ // If update is "none" then we don't have to apply a name. Since we won't animate this boundary.
478
+ return;
479
}
480
applyViewTransitionToHostInstances(
481
current.child,
496
const name = getViewTransitionName(props, child.stateNode);
497
const className: ?string = getViewTransitionClassName(
498
props.className,
503
- props.layout,
499
+ props.update,
500
);
501
if (className !== 'none') {
502
applyViewTransitionToHostInstances(
586
}
587
}
588
593
-export function cancelViewTransitionHostInstances(
594
- child: null | Fiber,
595
- oldName: string,
596
- stopAtNestedViewTransitions: boolean,
597
-): void {
598
- viewTransitionHostInstanceIdx = 0;
599
- cancelViewTransitionHostInstancesRecursive(
600
- child,
601
- oldName,
602
- stopAtNestedViewTransitions,
603
- );
604
-}
605
-
606
-function cancelViewTransitionHostInstancesRecursive(
607
- child: null | Fiber,
608
- oldName: string,
609
- stopAtNestedViewTransitions: boolean,
610
-): void {
611
- if (!supportsMutation) {
612
- return;
613
- }
614
- while (child !== null) {
615
- if (child.tag === HostComponent) {
616
- const instance: Instance = child.stateNode;
617
- if (viewTransitionCancelableChildren === null) {
618
- viewTransitionCancelableChildren = [];
619
- }
620
- viewTransitionCancelableChildren.push(
621
- instance,
622
- oldName,
623
- child.memoizedProps,
624
- );
625
- viewTransitionHostInstanceIdx++;
626
- } else if (
627
- child.tag === OffscreenComponent &&
628
- child.memoizedState !== null
629
- ) {
630
- // Skip any hidden subtrees. They were or are effectively not there.
631
- } else if (
632
- child.tag === ViewTransitionComponent &&
633
- stopAtNestedViewTransitions
634
- ) {
635
- // Skip any nested view transitions for updates since in that case the
636
- // inner most one is the one that handles the update.
637
- } else {
638
- cancelViewTransitionHostInstancesRecursive(
639
- child.child,
640
- oldName,
641
- stopAtNestedViewTransitions,
642
- );
643
- }
644
- child = child.sibling;
645
- }
646
-}
647
-
589
export function measureViewTransitionHostInstances(
590
parentViewTransition: Fiber,
591
child: null | Fiber,
733
const state: ViewTransitionState = newFiber.stateNode;
734
const newName = getViewTransitionName(props, state);
735
const oldName = getViewTransitionName(oldFiber.memoizedProps, state);
795
- const updateClassName: ?string = getViewTransitionClassName(
736
+ // Whether it ends up having been updated or relayout we apply the update class name.
737
+ const className: ?string = getViewTransitionClassName(
738
props.className,
739
props.update,
740
);
799
- const layoutClassName: ?string = getViewTransitionClassName(
800
- props.className,
801
- props.layout,
802
- );
803
- let className: ?string;
804
- if (updateClassName === 'none') {
805
- if (layoutClassName === 'none') {
806
- // If both update and layout class name were none, then we didn't apply any
807
- // names in the before update phase so we shouldn't now neither.
808
- return false;
809
- }
810
- // We don't care if this is mutated or children layout changed, but we still
811
- // measure each instance to see if it moved and therefore should apply layout.
812
- finishedWork.flags &= ~Update;
813
- className = layoutClassName;
814
- } else if ((finishedWork.flags & Update) !== NoFlags) {
815
- // It was updated and we have an appropriate class name to apply.
816
- className = updateClassName;
817
- } else {
818
- if (layoutClassName === 'none') {
819
- // If we did not update, then all changes are considered a layout. We'll
820
- // attempt to cancel.
821
- // This should use the Fiber that got names applied in the snapshot phase
822
- // since those are the ones we're trying to cancel.
823
- cancelViewTransitionHostInstances(oldFiber.child, oldName, true);
824
- return false;
825
- }
826
- // We didn't update but we might still apply layout so we measure each
827
- // instance to see if it moved or resized.
828
- className = layoutClassName;
741
+ if (className === 'none') {
742
+ // If update is "none" then we don't have to apply a name. Since we won't animate this boundary.
743
+ return false;
744
}
745
// If nothing changed due to a mutation, or children changing size
746
// and the measurements end up unchanged, we should restore it to not animate.
788
const name = getViewTransitionName(props, state);
789
const className: ?string = getViewTransitionClassName(
790
props.className,
876
- props.layout,
791
+ props.update,
792
);
793
let previousMeasurements: null | Array<InstanceMeasurement>;
794
if (gesture) {
817
if (gesture) {
818
// TODO: Schedule gesture events.
819
} else {
905
- scheduleViewTransitionEvent(child, props.onLayout);
820
+ scheduleViewTransitionEvent(child, props.onUpdate);
821
}
822
}
823
} else if ((child.subtreeFlags & ViewTransitionStatic) !== NoFlags) {