Skip to content

Commit 8209191

Browse files
adding loading animations
1 parent c1c2082 commit 8209191

File tree

3 files changed

+43
-1
lines changed

3 files changed

+43
-1
lines changed

app.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,13 @@ async function loadMatches() {
267267
}
268268
}
269269
}
270+
271+
function hideIframeLoader(iframe) {
272+
const wrapper = iframe.parentElement;
273+
wrapper.querySelector('.iframe-loader').style.display = 'none';
274+
iframe.style.visibility = 'visible';
275+
}
276+
270277
/*
271278
// Reload matches every 30 seconds
272279
setInterval(() => {

index.html

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,10 @@ <h1>Welcome to the Year 8 Chess Tournament</h1>
2525
<div id="game-panel" style="display:none; text-align: center;">
2626
<h2>Your Current Game</h2>
2727
<a id="game-link" href="#" target="_blank">Join Game</a><br><br>
28-
<iframe id="userGame" src="" allowfullscreen></iframe>
28+
<div class="iframe-wrapper">
29+
<div class="iframe-loader"></div>
30+
<iframe id="userGame" src="" width="240" height="240" onload="hideIframeLoader(this)"></iframe>
31+
</div>
2932
<br>
3033
<button onclick="reportTroll()">Report Opponent</button>
3134
</div>

style.css

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,38 @@ iframe#userGame {
9090
margin: 1rem auto;
9191
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
9292
}
93+
94+
.iframe-wrapper {
95+
position: relative;
96+
width: 240px;
97+
height: 240px;
98+
}
99+
100+
.iframe-loader {
101+
position: absolute;
102+
top: 50%;
103+
left: 50%;
104+
width: 40px;
105+
height: 40px;
106+
margin: -20px 0 0 -20px;
107+
border: 4px solid #ccc;
108+
border-top: 4px solid #4CAF50;
109+
border-radius: 50%;
110+
animation: spin 1s linear infinite;
111+
z-index: 2;
112+
}
113+
114+
.iframe-wrapper iframe {
115+
position: relative;
116+
z-index: 1;
117+
visibility: hidden;
118+
}
119+
120+
@keyframes spin {
121+
to {
122+
transform: rotate(360deg);
123+
}
124+
}
93125

94126
#leaderboard {
95127
margin: 2rem auto;

0 commit comments

Comments
 (0)