From 11eda5840a121f5e23b18336d6fd08e9bc96c7f8 Mon Sep 17 00:00:00 2001 From: sedsedus Date: Sun, 24 Sep 2023 10:44:48 +0200 Subject: [PATCH 1/5] Fix the loading spinner - it wasn't shown at all after d12c19da37de943d06703bec09613cf7121a70f9 - now it is shown, and then hidden when loading is done --- Cargo.lock | 1 + Cargo.toml | 3 +++ index.html | 8 ++++++++ src/main.rs | 9 +++++++++ 4 files changed, 21 insertions(+) diff --git a/Cargo.lock b/Cargo.lock index aac4da5f..f1646ad8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -746,6 +746,7 @@ dependencies = [ "log", "serde", "wasm-bindgen-futures", + "web-sys", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index 45c682c0..a9f3259c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -27,6 +27,9 @@ env_logger = "0.10" [target.'cfg(target_arch = "wasm32")'.dependencies] wasm-bindgen-futures = "0.4" +# to access the DOM (to hide the loading text) +[target.'cfg(target_arch = "wasm32")'.dependencies.web-sys] +version = "0.3.4" [profile.release] opt-level = 2 # fast and small wasm diff --git a/index.html b/index.html index 872b4f4c..278fa78a 100644 --- a/index.html +++ b/index.html @@ -119,6 +119,14 @@ + +
+

+ Loading… +

+
+
+ diff --git a/src/main.rs b/src/main.rs index a4dbe96e..af0fa732 100644 --- a/src/main.rs +++ b/src/main.rs @@ -31,5 +31,14 @@ fn main() { ) .await .expect("failed to start eframe"); + // Loading done - hide the loading text + let hide_loading_text_if_exists = || -> Option<()> { + web_sys::window()? + .document()? + .get_element_by_id("loading_text")? + .remove(); + Some(()) + }; + let _ = hide_loading_text_if_exists(); }); } From 460d0dbd9b0c4ced408342f7a593d94d65b81bf8 Mon Sep 17 00:00:00 2001 From: sedsedus Date: Sun, 24 Sep 2023 11:43:25 +0200 Subject: [PATCH 2/5] Handle failed start case --- index.html | 9 ++++----- src/main.rs | 26 ++++++++++++++------------ 2 files changed, 18 insertions(+), 17 deletions(-) diff --git a/index.html b/index.html index 278fa78a..154800de 100644 --- a/index.html +++ b/index.html @@ -114,11 +114,14 @@ transform: rotate(360deg); } } - + + + +

@@ -127,10 +130,6 @@

- - - -