Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions demo/src/native-ui-shell-transition.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,10 @@ const fixture = () => {
return { animation, calls, ready, finish: (step: 0 | 1) => finish(step, animation) };
};

test('normal transition waits for native suspension', async () => {
test('play starts before native suspension settles', async () => {
const { animation, calls, ready } = fixture();
const played = animation.play();
expect(calls).toEqual([]);
expect(calls).toEqual(['play']);
ready();
await played;
expect(calls).toEqual(['play', 'resume:false']);
Expand All @@ -87,7 +87,7 @@ test('destroy during bridge preparation cannot start an abandoned transition', a
animation.destroy();
ready();
await played;
expect(calls).toEqual(['destroy', 'resume:true']);
expect(calls).toEqual(['play', 'destroy', 'resume:true']);
});

test('without native enablement the animation remains untouched', () => {
Expand Down
5 changes: 4 additions & 1 deletion packages/theme-ios27/src/transition/native-ui.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,14 @@ export const connectNativeUIShellTransition = (animation: Animation, entering: H
};
animation.onFinish((step) => finish(step === 0));
animation.play = async (options) => {
await prepare();
// Overlap suspend with the slide. Awaiting it first retires native chrome while the page is still
// at rest, which flashes Web for a frame before the slide starts.
const ready = prepare();
if (disposed) return;
try {
await play(options);
} finally {
await ready;
finish();
}
};
Expand Down
Loading