Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit4717856

Browse files
committed
[fix] signal that pings pause prio to alert opening
Fixessveltejs#126
1 parentd4ef7c9 commit4717856

File tree

2 files changed

+21
-3
lines changed

2 files changed

+21
-3
lines changed

‎content/tutorial/common/src/__client.js‎

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,19 @@
1+
// Hack into the alert that's used in some tutorials and send a message prior to the alert,
2+
// else the parent thinks we lost contact and wrongfully reloads the page.
3+
// The drawback is that alert is no longer blocking, but no tutorial relies on this.
4+
constalert=window.alert;
5+
window.alert=(message)=>{
6+
parent.postMessage(
7+
{
8+
type:'ping-pause'
9+
},
10+
'*'
11+
);
12+
setTimeout(()=>{
13+
alert(message);
14+
});
15+
};
16+
117
window.addEventListener('message',async(e)=>{
218
if(e.data.type==='fetch'){
319
constnames=e.data.names;
@@ -59,7 +75,7 @@ function ping() {
5975
);
6076
}
6177

62-
setInterval(ping,50);
78+
setInterval(ping,100);
6379
ping();
6480

6581
if(import.meta.hot){

‎src/routes/tutorial/[slug]/+page.svelte‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@
254254
if (e.origin!==adapter.base)return;
255255
256256
if (e.data.type==='ping') {
257-
path=e.data.data.path;
257+
path=e.data.data.path?? path;
258258
259259
clearTimeout(timeout);
260260
timeout=setTimeout(()=> {
@@ -264,7 +264,9 @@
264264
loading=true;
265265
set_iframe_src(adapter.base+ path);
266266
loading=false;
267-
},500);
267+
},1000);
268+
}elseif (e.data.type==='ping-pause') {
269+
clearTimeout(timeout);
268270
}
269271
}
270272

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp