Skip to content

Commit deea2c8

Browse files
committed
View Transition Events (facebook#32041)
This adds five events to `<ViewTransition>` that triggers when React wants to animate it. - `onEnter`: The `<ViewTransition>` or its parent Component is mounted and there's no other `<ViewTransition>` with the same name being deleted. - `onExit`: The `<ViewTransition>` or its parent Component is unmounted and there's no other `<ViewTransition>` with the same name being deleted. - `onLayout`: There are no updates to the content inside this `<ViewTransition>` boundary itself but the boundary has resized or moved due to other changes to siblings. - `onShare`: This `<ViewTransition>` is being mounted and another `<ViewTransition>` instance with the same name is being unmounted elsewhere. - `onUpdate`: The content of `<ViewTransition>` has changed either due to DOM mutations or because an inner child `<ViewTransition>` has resized. Only one of these events is fired per Transition. If you want to cover all updates you have to listen to `onLayout`, `onShare` and `onUpdate`. We could potentially do something like fire `onUpdate` if `onLayout` or `onShare` isn't specified but it's a little sketchy to have behavior based on if someone is listening since it limits adding wrappers that may or may not need it. Each takes a `ViewTransitionInstance` as an argument so you don't need a ref to animate it. ```js <ViewTransition onEnter={inst => inst.new.animate(keyframes, options)}> ``` The timing of this event is after the View Transition's `ready` state which means that's too late to do any changes to the View Transition's snapshots but now both the new and old pseudo-elements are ready to animate. The order of `onExit` is parent first, where as the others are child first. This mimics effect mount/unmount. I implement this by adding to a queue in the commit phase and then call it while we're finishing up the commit. This is after layout effects but before passive effects since passive effects fire after the animation is `finished`. DiffTrain build for [540efeb](facebook@540efeb)
1 parent 8387e73 commit deea2c8

34 files changed

+185
-186
lines changed

compiled/facebook-www/REVISION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0bf1f39ec6906c666011c0c57aa56aa34a262daf
1+
540efebcc34357c98412a96805bfd9244d6aa678
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0bf1f39ec6906c666011c0c57aa56aa34a262daf
1+
540efebcc34357c98412a96805bfd9244d6aa678

compiled/facebook-www/React-dev.classic.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1944,7 +1944,7 @@ __DEV__ &&
19441944
exports.useTransition = function () {
19451945
return resolveDispatcher().useTransition();
19461946
};
1947-
exports.version = "19.1.0-www-classic-0bf1f39e-20250110";
1947+
exports.version = "19.1.0-www-classic-540efebc-20250112";
19481948
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
19491949
"function" ===
19501950
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop &&

compiled/facebook-www/React-dev.modern.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1944,7 +1944,7 @@ __DEV__ &&
19441944
exports.useTransition = function () {
19451945
return resolveDispatcher().useTransition();
19461946
};
1947-
exports.version = "19.1.0-www-modern-0bf1f39e-20250110";
1947+
exports.version = "19.1.0-www-modern-540efebc-20250112";
19481948
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
19491949
"function" ===
19501950
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop &&

compiled/facebook-www/React-prod.classic.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -630,4 +630,4 @@ exports.useSyncExternalStore = function (
630630
exports.useTransition = function () {
631631
return ReactSharedInternals.H.useTransition();
632632
};
633-
exports.version = "19.1.0-www-classic-0bf1f39e-20250110";
633+
exports.version = "19.1.0-www-classic-540efebc-20250112";

compiled/facebook-www/React-prod.modern.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -630,4 +630,4 @@ exports.useSyncExternalStore = function (
630630
exports.useTransition = function () {
631631
return ReactSharedInternals.H.useTransition();
632632
};
633-
exports.version = "19.1.0-www-modern-0bf1f39e-20250110";
633+
exports.version = "19.1.0-www-modern-540efebc-20250112";

compiled/facebook-www/React-profiling.classic.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -634,7 +634,7 @@ exports.useSyncExternalStore = function (
634634
exports.useTransition = function () {
635635
return ReactSharedInternals.H.useTransition();
636636
};
637-
exports.version = "19.1.0-www-classic-0bf1f39e-20250110";
637+
exports.version = "19.1.0-www-classic-540efebc-20250112";
638638
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
639639
"function" ===
640640
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop &&

compiled/facebook-www/React-profiling.modern.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -634,7 +634,7 @@ exports.useSyncExternalStore = function (
634634
exports.useTransition = function () {
635635
return ReactSharedInternals.H.useTransition();
636636
};
637-
exports.version = "19.1.0-www-modern-0bf1f39e-20250110";
637+
exports.version = "19.1.0-www-modern-540efebc-20250112";
638638
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
639639
"function" ===
640640
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop &&

compiled/facebook-www/ReactART-dev.classic.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1059,9 +1059,6 @@ __DEV__ &&
10591059
: pop(didPerformWorkStackCursor, workInProgress);
10601060
push(didPerformWorkStackCursor, didChange, workInProgress);
10611061
}
1062-
function is(x, y) {
1063-
return (x === y && (0 !== x || 1 / x === 1 / y)) || (x !== x && y !== y);
1064-
}
10651062
function disabledLog() {}
10661063
function disableLogs() {
10671064
if (0 === disabledDepth) {
@@ -1923,6 +1920,9 @@ __DEV__ &&
19231920
(hydrationErrors = null));
19241921
return queuedErrors;
19251922
}
1923+
function is(x, y) {
1924+
return (x === y && (0 !== x || 1 / x === 1 / y)) || (x !== x && y !== y);
1925+
}
19261926
function resetContextDependencies() {
19271927
lastContextDependency = currentlyRenderingFiber$1 = null;
19281928
isDisallowedContextReadInDEV = !1;
@@ -14809,7 +14809,6 @@ __DEV__ &&
1480914809
var contextStackCursor$1 = createCursor(emptyContextObject),
1481014810
didPerformWorkStackCursor = createCursor(!1),
1481114811
previousContext = emptyContextObject,
14812-
objectIs = "function" === typeof Object.is ? Object.is : is,
1481314812
disabledDepth = 0,
1481414813
prevLog,
1481514814
prevInfo,
@@ -14833,6 +14832,7 @@ __DEV__ &&
1483314832
needsEscaping = /["'&<>\n\t]|^\s|\s$/,
1483414833
hydrationDiffRootDEV = null,
1483514834
hydrationErrors = null,
14835+
objectIs = "function" === typeof Object.is ? Object.is : is,
1483614836
valueCursor = createCursor(null);
1483714837
var renderer2CursorDEV = createCursor(null);
1483814838
var rendererSigil = {};
@@ -16945,10 +16945,10 @@ __DEV__ &&
1694516945
(function () {
1694616946
var internals = {
1694716947
bundleType: 1,
16948-
version: "19.1.0-www-classic-0bf1f39e-20250110",
16948+
version: "19.1.0-www-classic-540efebc-20250112",
1694916949
rendererPackageName: "react-art",
1695016950
currentDispatcherRef: ReactSharedInternals,
16951-
reconcilerVersion: "19.1.0-www-classic-0bf1f39e-20250110"
16951+
reconcilerVersion: "19.1.0-www-classic-540efebc-20250112"
1695216952
};
1695316953
internals.overrideHookState = overrideHookState;
1695416954
internals.overrideHookStateDeletePath = overrideHookStateDeletePath;
@@ -16982,7 +16982,7 @@ __DEV__ &&
1698216982
exports.Shape = Shape;
1698316983
exports.Surface = Surface;
1698416984
exports.Text = Text;
16985-
exports.version = "19.1.0-www-classic-0bf1f39e-20250110";
16985+
exports.version = "19.1.0-www-classic-540efebc-20250112";
1698616986
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
1698716987
"function" ===
1698816988
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop &&

compiled/facebook-www/ReactART-dev.modern.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -965,9 +965,6 @@ __DEV__ &&
965965
fiberStack[index$jscomp$0] = fiber;
966966
cursor.current = value;
967967
}
968-
function is(x, y) {
969-
return (x === y && (0 !== x || 1 / x === 1 / y)) || (x !== x && y !== y);
970-
}
971968
function disabledLog() {}
972969
function disableLogs() {
973970
if (0 === disabledDepth) {
@@ -1829,6 +1826,9 @@ __DEV__ &&
18291826
(hydrationErrors = null));
18301827
return queuedErrors;
18311828
}
1829+
function is(x, y) {
1830+
return (x === y && (0 !== x || 1 / x === 1 / y)) || (x !== x && y !== y);
1831+
}
18321832
function resetContextDependencies() {
18331833
lastContextDependency = currentlyRenderingFiber$1 = null;
18341834
isDisallowedContextReadInDEV = !1;
@@ -14582,8 +14582,7 @@ __DEV__ &&
1458214582
var index$jscomp$0 = -1,
1458314583
emptyContextObject = {};
1458414584
Object.freeze(emptyContextObject);
14585-
var objectIs = "function" === typeof Object.is ? Object.is : is,
14586-
disabledDepth = 0,
14585+
var disabledDepth = 0,
1458714586
prevLog,
1458814587
prevInfo,
1458914588
prevWarn,
@@ -14606,6 +14605,7 @@ __DEV__ &&
1460614605
needsEscaping = /["'&<>\n\t]|^\s|\s$/,
1460714606
hydrationDiffRootDEV = null,
1460814607
hydrationErrors = null,
14608+
objectIs = "function" === typeof Object.is ? Object.is : is,
1460914609
valueCursor = createCursor(null);
1461014610
var renderer2CursorDEV = createCursor(null);
1461114611
var rendererSigil = {};
@@ -16717,10 +16717,10 @@ __DEV__ &&
1671716717
(function () {
1671816718
var internals = {
1671916719
bundleType: 1,
16720-
version: "19.1.0-www-modern-0bf1f39e-20250110",
16720+
version: "19.1.0-www-modern-540efebc-20250112",
1672116721
rendererPackageName: "react-art",
1672216722
currentDispatcherRef: ReactSharedInternals,
16723-
reconcilerVersion: "19.1.0-www-modern-0bf1f39e-20250110"
16723+
reconcilerVersion: "19.1.0-www-modern-540efebc-20250112"
1672416724
};
1672516725
internals.overrideHookState = overrideHookState;
1672616726
internals.overrideHookStateDeletePath = overrideHookStateDeletePath;
@@ -16754,7 +16754,7 @@ __DEV__ &&
1675416754
exports.Shape = Shape;
1675516755
exports.Surface = Surface;
1675616756
exports.Text = Text;
16757-
exports.version = "19.1.0-www-modern-0bf1f39e-20250110";
16757+
exports.version = "19.1.0-www-modern-540efebc-20250112";
1675816758
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
1675916759
"function" ===
1676016760
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop &&

0 commit comments

Comments
 (0)