Skip to content

Commit db30420

Browse files
committed
fix
1 parent 8b2846b commit db30420

4 files changed

Lines changed: 48 additions & 34 deletions

File tree

JetStream.css

Lines changed: 23 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
--benchmark-done-result-color: #4A4A4A;
4242
--gap: 3rem;
4343
--width: 200px;
44+
--startup-animation-duration: 500ms;
4445
}
4546

4647
html,
@@ -180,7 +181,7 @@ img {
180181
}
181182

182183
.loading.animate .logo .logo-image {
183-
animation: swingin 350ms ease-out forwards;
184+
animation: swingin var(--startup-animation-duration) ease-out forwards;
184185
will-change: transform, opacity;
185186
animation-delay: 50ms;
186187
}
@@ -196,19 +197,21 @@ img {
196197
background-position: center;
197198
padding: 2rem 0;
198199
margin: -2rem 0;
200+
background-image: url("img/jetstreams-static.svg");
199201
}
200202

203+
201204
#jetstreams svg {
202205
width: 100%;
203206
max-height: 120px;
204207
}
205208

206-
.loading.animate #jetstreams {
209+
.animate #jetstreams {
207210
background-image: url("img/jetstreams.svg");
211+
transition: background-image var(--startup-animation-duration) ease-in-out;
208212
}
209-
210-
.loading #jetstreams, .ready #jetstreams {
211-
background-image: url("img/jetstreams-static.svg");
213+
.ready #jetstreams {
214+
background-image: url("img/jetstreams-static.svg") !important;
212215
}
213216

214217
#magic {
@@ -239,7 +242,7 @@ article,
239242
}
240243

241244
article, .loading.animate .summary {
242-
animation: fadein 0.5s ease-in-out forwards;
245+
animation: fadein var(--startup-animation-duration) ease-in-out forwards;
243246
animation-delay: 200ms;
244247
}
245248

@@ -325,12 +328,18 @@ a.button {
325328
user-select: none;
326329
}
327330

331+
.animate a.button {
332+
animation: fadein var(--startup-animation-duration) ease-in forwards, scaledown var(--startup-animation-duration) ease-in forwards;
333+
opacity: 0;
334+
}
335+
336+
328337
#status label,
329338
.button:hover {
330339
background-image: none;
331340
}
332341

333-
.loading #status{
342+
.loading #status-counter {
334343
position: absolute;
335344
top: 0;
336345
left: 0;
@@ -404,14 +413,13 @@ a.button {
404413
justify-content: space-around;
405414
gap: var(--gap);
406415
margin: 0 calc(var(--gap) * -1) 0 calc(-var(--gap) * -1);
407-
animation: fadein 500ms ease-out forwards;
408-
opacity: 0;
409416
overflow-y: auto;
410417
flex: 1;
411418
padding-bottom: var(--gap);
412419
box-sizing: border-box;
413420
}
414421

422+
415423
.benchmark {
416424
position: relative;
417425
flex: 1;
@@ -424,6 +432,12 @@ a.button {
424432
scroll-margin-bottom: 20vh;
425433
}
426434

435+
.animate .benchmark {
436+
animation: fadein var(--startup-animation-duration) ease-in forwards;
437+
opacity: 0;
438+
}
439+
440+
427441
.benchmark .result.detail {
428442
display: none;
429443
}
@@ -611,16 +625,6 @@ dt:target {
611625
}
612626
}
613627

614-
@keyframes shine {
615-
0% {
616-
background-position: -1200px center;
617-
}
618-
619-
100% {
620-
background-position: 100vw center;
621-
}
622-
}
623-
624628
@keyframes swingin {
625629
from {
626630
opacity: 0;

JetStreamDriver.js

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -217,10 +217,7 @@ class Driver {
217217
// the global `fileLoader` cache.
218218
this.blobDataCache = { };
219219
this.loadCache = { };
220-
this.counter = { };
221-
this.counter.loadedResources = 0;
222-
this.counter.totalResources = 0;
223-
this.counter.failedPreloadResources = 0;
220+
this.counter = { loadedResources: 0, totalResources: 0, failedPreloadResources: 0 };
224221
}
225222

226223
async start() {
@@ -356,7 +353,7 @@ class Driver {
356353
}
357354
}
358355

359-
prepareBrowserUI() {
356+
async prepareBrowserUI() {
360357
let text = "";
361358
for (const benchmark of this.benchmarks)
362359
text += benchmark.renderHTML();
@@ -370,15 +367,28 @@ class Driver {
370367
JetStream.start();
371368
});
372369

370+
document.body.classList.add("ready");
373371
const statusElement = document.getElementById("status");
374372
statusElement.innerHTML = `<a href="javascript:JetStream.start()" class="button">Start Test</a>`;
373+
374+
await this.waitForBrowserUIStartupAnimation();
375+
375376
statusElement.addEventListener("click", (e) => {
376377
e.preventDefault();
377378
JetStream.start();
378379
return false;
379380
}, { once: true});
380381
}
381382

383+
384+
async waitForBrowserUIStartupAnimation() {
385+
if (!JetStreamParams.isDefault)
386+
return
387+
const cssValue = window.getComputedStyle(document.body).getPropertyValue("--startup-animation-duration");
388+
const startupAnimationDuration = parseInt(cssValue.split("ms")[0])
389+
await new Promise((resolve) => setTimeout(resolve, startupAnimationDuration));
390+
}
391+
382392
reportError(benchmark, error) {
383393
this.pushError(benchmark.name, error);
384394

@@ -408,7 +418,7 @@ class Driver {
408418
await this.prefetchResources();
409419
this.benchmarks.sort((a, b) => a.plan.name.toLowerCase() < b.plan.name.toLowerCase() ? 1 : -1);
410420
if (isInBrowser)
411-
this.prepareBrowserUI();
421+
await this.prepareBrowserUI();
412422
this.isReady = true;
413423
if (isInBrowser) {
414424
globalThis.dispatchEvent(new Event("JetStreamReady"));
@@ -1041,7 +1051,7 @@ class Benchmark {
10411051
updateCounter() {
10421052
const counter = JetStream.counter;
10431053
++counter.loadedResources;
1044-
const statusElement = document.getElementById("status");
1054+
const statusElement = document.getElementById("status-counter");
10451055
statusElement.innerHTML = `Loading ${counter.loadedResources} of ${counter.totalResources} ...`;
10461056
}
10471057

img/jetstreams.svg

Lines changed: 5 additions & 5 deletions
Loading

index.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,13 +59,11 @@
5959
if (globalThis.allIsGood) {
6060
try {
6161
await JetStream.initialize();
62-
document.body.classList.add("ready");
6362
} catch (e) {
6463
globalThis.allIsGood = false;
6564
console.error(e);
6665
} finally {
6766
bodyClassList.remove("loading");
68-
bodyClassList.remove("animate-loading");
6967
}
7068
}
7169
if (!globalThis.allIsGood) {
@@ -121,7 +119,9 @@ <h2>Non-standard Parameters</h2>
121119
<p class="summary" id="mode-description"></p>
122120

123121
<div id="result-summary"></div>
124-
<div id="status">Loading Benchmark...</div>
122+
<div id="status">
123+
<div id="status-counter">Loading Benchmark...</div>
124+
</div>
125125

126126
<div id="results"></div>
127127
</main>

0 commit comments

Comments
 (0)