diff --git a/frontend/viewer.css b/frontend/viewer.css index 927ccef..063c469 100644 --- a/frontend/viewer.css +++ b/frontend/viewer.css @@ -6,3 +6,6 @@ html, body, #viewport { width: 100%; height: 100%; margin: 0; overflow: hidden; #viewport > svg { display: block; width: 100%; height: 100%; overflow: hidden; } #state { position: fixed; left: 50%; top: 50%; transform: translate(-50%,-50%); color: #333; font-size: 14px; text-align: center; } #state:empty { display: none; } +#state.loading { width: 28px; height: 28px; font-size: 0; border: 2px solid #dce2e0; border-top-color: #536963; border-radius: 50%; pointer-events: none; animation: loading-spin .8s linear infinite; } +@keyframes loading-spin { to { transform: translate(-50%,-50%) rotate(360deg); } } +@media (prefers-reduced-motion: reduce) { #state.loading { animation: none; } } diff --git a/frontend/viewer.html b/frontend/viewer.html index b980dc2..17792b3 100644 --- a/frontend/viewer.html +++ b/frontend/viewer.html @@ -1,2 +1,2 @@ -Schematic
+Schematic
Loading schematic… diff --git a/frontend/viewer.js b/frontend/viewer.js index df834f3..6f07610 100644 --- a/frontend/viewer.js +++ b/frontend/viewer.js @@ -46,6 +46,7 @@ async function start() { viewport.append(svg); await document.fonts.ready; viewport.style.backgroundColor = background; + state.classList.remove('loading'); state.textContent = ''; paint(); viewport.addEventListener('wheel', e => { @@ -93,4 +94,7 @@ async function start() { } expire(); } -start().catch(e => { if (e.name !== 'AbortError') state.textContent = e.message; }); +start().catch(e => { + state.classList.remove('loading'); + state.textContent = e.name === 'AbortError' ? '' : e.message; +});