File tree Expand file tree Collapse file tree 2 files changed +19
-1
lines changed
view-transition/src/components Expand file tree Collapse file tree 2 files changed +19
-1
lines changed Original file line number Diff line number Diff line change 22
33import { setServerState } from './ServerState.js' ;
44
5+ async function sleep ( ms ) {
6+ return new Promise ( resolve => setTimeout ( resolve , ms ) ) ;
7+ }
8+
59export async function like ( ) {
10+ // Test loading state
11+ await sleep ( 1000 ) ;
612 setServerState ( 'Liked!' ) ;
713 return new Promise ( ( resolve , reject ) => resolve ( 'Liked' ) ) ;
814}
@@ -20,5 +26,7 @@ export async function greet(formData) {
2026}
2127
2228export async function increment ( n ) {
29+ // Test loading state
30+ await sleep ( 1000 ) ;
2331 return n + 1 ;
2432}
Original file line number Diff line number Diff line change @@ -18,6 +18,10 @@ import './Page.css';
1818
1919import transitions from './Transitions.module.css' ;
2020
21+ async function sleep ( ms ) {
22+ return new Promise ( resolve => setTimeout ( resolve , ms ) ) ;
23+ }
24+
2125const a = (
2226 < div key = "a" >
2327 < ViewTransition >
@@ -106,7 +110,13 @@ export default function Page({url, navigate}) {
106110 document . body
107111 )
108112 ) : (
109- < button onClick = { ( ) => startTransition ( ( ) => setShowModal ( true ) ) } >
113+ < button
114+ onClick = { ( ) =>
115+ startTransition ( async ( ) => {
116+ setShowModal ( true ) ;
117+ await sleep ( 2000 ) ;
118+ } )
119+ } >
110120 Show Modal
111121 </ button >
112122 ) ;
You can’t perform that action at this time.
0 commit comments