Skip to content

Commit 5293716

Browse files
authored
Implement word rotation for astronaut titles
Add dynamic word changing effect for astronauts in flights.
1 parent fd4027f commit 5293716

1 file changed

Lines changed: 22 additions & 0 deletions

File tree

space-astro.html

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -334,6 +334,28 @@
334334
<div class="container">
335335
<h1 class="glow-text">Astronauts in flights</h1>
336336
<div id="astronautsData">Loading...</div>
337+
<script>const words = ["Cosmonauts", "Astronauts", "Spationauts", "Taïkonauts"];
338+
let index = 0;
339+
340+
const h1 = document.querySelector('.glow-text');
341+
// Wrap the changing word in a span
342+
h1.innerHTML = `<span id="changing-word">${words[0]}</span> in flights`;
343+
344+
setInterval(() => {
345+
index = (index + 1) % words.length;
346+
const span = document.getElementById('changing-word');
347+
348+
// Fade out
349+
span.style.transition = 'opacity 0.4s';
350+
span.style.opacity = '0';
351+
352+
setTimeout(() => {
353+
span.textContent = words[index];
354+
span.style.opacity = '1'; // Fade in
355+
}, 400);
356+
357+
}, 2000);
358+
</script>
337359
</div>
338360

339361
<script>

0 commit comments

Comments
 (0)