diff --git a/src/common/util/viewTransitionUtils.ts b/src/common/util/viewTransitionUtils.ts new file mode 100644 index 000000000..4a4a744a3 --- /dev/null +++ b/src/common/util/viewTransitionUtils.ts @@ -0,0 +1,40 @@ +// import { flushSync } from 'react-dom'; +// +// +// // Provide the missing definition for this novel API +// +// // Extend the global Document interface +// declare global { +// interface Document { +// startViewTransition(updateCallback: UpdateCallback): ViewTransition; +// } +// } +// +// type UpdateCallback = () => Promise; +// +// interface ViewTransition { +// readonly updateCallbackDone: Promise; +// readonly ready: Promise; +// readonly finished: Promise; +// +// skipTransition(): undefined; +// } +// +// +// // Perform a view transition, if supported by the browser +// export async function performViewTransition(callback: () => T) { +// +// // If the browser does not support view transitions, just call the callback +// if (!('startViewTransition' in document)) +// return callback(); +// +// // Transition to the new view +// const viewTransition = document.startViewTransition(async () => { +// if (typeof flushSync !== 'function') +// return callback(); +// return flushSync(() => callback()); +// }); +// +// // Wait for the transition to be ready +// // await viewTransition.ready; +// }