From 6146da5eb71da2942fa3da9dfdd8a5cc5f3734d9 Mon Sep 17 00:00:00 2001
From: Joe <33972521+hnb-ku@users.noreply.github.com>
Date: Wed, 29 Jun 2022 18:01:46 +0800
Subject: [PATCH] DEV: Use `performance.timing` as a baseline for the splash
(#17275)
* update styles
* remove unused code
* use request time as a baseline
---
app/assets/javascripts/discourse/app/app.js | 9 ---
app/views/common/_discourse_splash.html.erb | 74 ++++++++++++++++++---
public/images/preloader.svg | 29 ++++----
3 files changed, 81 insertions(+), 31 deletions(-)
diff --git a/app/assets/javascripts/discourse/app/app.js b/app/assets/javascripts/discourse/app/app.js
index be305596c42..19da3d28362 100644
--- a/app/assets/javascripts/discourse/app/app.js
+++ b/app/assets/javascripts/discourse/app/app.js
@@ -81,15 +81,6 @@ const Discourse = Application.extend({
initialize: () => withPluginApi(cb.version, cb.code),
});
});
-
- window.addEventListener(
- "load",
- () => {
- // The app booted. Remove the splash screen
- document.querySelector("#d-splash")?.remove();
- },
- { once: true }
- );
},
_registerPluginCode(version, code) {
diff --git a/app/views/common/_discourse_splash.html.erb b/app/views/common/_discourse_splash.html.erb
index 08b92b65f53..25f5a9dcd3e 100644
--- a/app/views/common/_discourse_splash.html.erb
+++ b/app/views/common/_discourse_splash.html.erb
@@ -9,13 +9,14 @@
display: grid;
place-items: center;
backface-visibility: hidden;
+ background: var(--secondary);
position: absolute;
left: 0;
top: 0;
height: 100%;
width: 100%;
- z-index: 1001; /* above the header */
- background: var(--secondary);
+ z-index: 1001;
+ --animation-state: paused;
}
#d-splash .preloader-image {
@@ -25,22 +26,26 @@
#d-splash .preloader-text {
padding-top: 4em;
- position: absolute;
- opacity: 0;
- animation: fade-in 0.5s ease-in-out;
- animation-delay: 2.5s;
- animation-fill-mode: forwards;
- color: var(--primary);
+ position: absolute;
+ opacity: 0;
+ animation: fade-in 0.5s ease-in-out;
+ animation-delay: 1s;
+ animation-fill-mode: forwards;
+ animation-play-state: var(--animation-state);
+ color: var(--primary);
}
#d-splash .preloader-text:after {
animation: loading-text 3s infinite;
content: "";
position: absolute;
+ top: 4em;
margin: 0 0.1em;
+ left: 100%;
}
.rtl #d-splash .preloader-text:after {
+ left: 0;
right: 100%;
}
@@ -71,7 +76,7 @@
@@ -90,5 +95,56 @@
}
+
+
<%- end %>
diff --git a/public/images/preloader.svg b/public/images/preloader.svg
index b4101b4d679..b2319c1b2fb 100644
--- a/public/images/preloader.svg
+++ b/public/images/preloader.svg
@@ -1,6 +1,9 @@
-