Add animation

This commit is contained in:
Augusto Gunsch 2023-11-11 12:48:55 +01:00
parent b977af751c
commit ea7289c5fc
3 changed files with 155 additions and 46 deletions

View File

@ -1,37 +1,43 @@
let language = 'en'; function simulateCommandPrompt(element, texts, speed, wait) {
const outputElement = document.getElementById(element);
const cursor = document.createElement('span');
cursor.classList.add('cursor');
cursor.textContent = '█';
function loadPage(navButton) { let currentIndex = 0;
const selected = document.getElementsByClassName('selected')[0];
if (selected != navButton) { function typeText() {
const xhttp = new XMLHttpRequest(); const text = texts[currentIndex];
const content = document.getElementById('content'); let i = 0;
const page = navButton.id;
if(page != 'index') { function typeCharacter() {
window.location.hash = page; if (i <= text.length) {
window.document.title = `Augusto Gunsch | ${navButton.innerHTML}`; outputElement.textContent = text.slice(0, i);
} else { outputElement.appendChild(cursor);
history.replaceState(null, null, ' '); i++;
window.document.title = 'Augusto Gunsch'; setTimeout(typeCharacter, speed);
} } else {
setTimeout(() => {
currentIndex = (currentIndex + 1) % texts.length;
outputElement.textContent = '';
outputElement.appendChild(cursor);
typeText();
}, wait);
}
}
xhttp.onload = function() { typeCharacter();
content.innerHTML = this.responseText; }
}
xhttp.open('GET', `${language}/${page}`, true);
selected.classList.remove('selected'); typeText();
navButton.classList.add('selected');
content.innerHTML = '<p>Loading...</p>';
xhttp.send();
}
} }
if(window.location.hash) { const texts = [
const page = window.location.hash.split('#')[1]; 'software',
const navButton = document.getElementById(page); 'reality',
console.log(navButton); 'solutions',
loadPage(navButton); 'innovation',
} 'technology'
];
simulateCommandPrompt('typing', texts, 100, 3000);

View File

@ -11,15 +11,12 @@
#body { #body {
background-color: #F2F2FF; background-color: #F2F2FF;
background-image: url("duck.png");
background-size: 50%;
background-repeat: no-repeat;
background-position: right bottom;
display: flex; display: flex;
margin: 0; margin: 0;
width: 100%; width: 100%;
font-family: "Noto Sans Mono", "Monaco", serif; font-family: "Noto Sans Mono", "Monaco", serif;
flex-direction: column; flex-direction: column;
position: relative;
} }
#header { #header {
@ -44,7 +41,6 @@
#links { #links {
display: flex; display: flex;
align-items: center; align-items: center;
flex-wrap: wrap;
justify-content: center; justify-content: center;
} }
@ -65,8 +61,7 @@
#page { #page {
display: flex; display: flex;
margin: 1rem; padding: 0 1rem 1rem;
margin-bottom: 4rem;
} }
#social { #social {
@ -105,6 +100,7 @@
#slogan { #slogan {
text-align: right; text-align: right;
font-size: 3rem; font-size: 3rem;
position: relative;
} }
#slogan mark { #slogan mark {
@ -114,9 +110,105 @@
position: relative; position: relative;
} }
#circle {
top: 0;
left: -20%;
position: absolute;
width: 140%;
aspect-ratio: 1 / 1;
background-color: #EDAF1F;
border-radius: 100%;
animation: pulse-circle 30s ease-in-out -2s infinite alternate;
z-index: -1;
}
#circle-behind {
top: 0;
left: -20%;
position: absolute;
width: 140%;
aspect-ratio: 1 / 1;
z-index: -2;
animation: rotate-circle 60s linear -2s infinite normal;
}
#circle-behind::after {
content: '';
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
animation: pulse-circle 30s ease-in-out -2s infinite alternate;
background-color: #d49a11;
border-radius: 100%;
}
@keyframes pulse-circle {
0% {
transform: scale(.9);
}
50% {
transform: scale(1);
}
100% {
transform: scale(.9);
}
}
@keyframes rotate-circle {
0% {
transform: translateX(5%);
}
25% {
transform: translateY(-5%);
}
50% {
transform: translateX(-5%);
}
75% {
transform: translateY(5%);
}
100% {
transform: translateX(5%);
}
}
.cursor {
animation: blink 0.8s infinite;
}
@keyframes blink {
50% {
opacity: 0;
}
}
@media only screen and (max-width: 600px) { @media only screen and (max-width: 600px) {
#body { #page {
background-image: none; flex-wrap: wrap-reverse;
}
#social {
flex-direction: row;
width: 100%;
gap: 1rem;
height: 50px;
margin-bottom: 1rem;
}
#social img {
height: 100%;
}
#circle, #circle-behind {
display: none;
} }
#main { #main {
@ -145,6 +237,7 @@
#links a { #links a {
margin: 0.3rem; margin: 0.3rem;
flex-wrap: wrap;
} }
} }
@ -155,10 +248,6 @@
} }
@media only screen and (max-width: 390px) { @media only screen and (max-width: 390px) {
#social {
display: none;
}
#links .button { #links .button {
border-radius: 7px; border-radius: 7px;
} }
@ -181,6 +270,7 @@
#page { #page {
height: 100%; height: 100%;
overflow-y: hidden;
} }
} }
@ -189,6 +279,16 @@
#quote { #quote {
max-width: 50%; max-width: 50%;
} }
#circle, #circle-behind {
top: -70%;
}
#page {
padding-top: 3rem;
padding-bottom: 3rem;
overflow: hidden;
}
} }
@media only screen and (min-width: 992px) { @media only screen and (min-width: 992px) {

View File

@ -37,10 +37,13 @@
</blockquote> </blockquote>
<figcaption>{{ author }}</figcaption> <figcaption>{{ author }}</figcaption>
</figure> </figure>
<span id="slogan"> <div id="slogan">
I turn <mark>ideas</mark><br>into<br><mark>software</mark>. <div id="circle"></div>
</span> <div id="circle-behind"></div>
I turn <mark>ideas</mark><br>into<br><mark id="typing"></mark>.
</div>
</main> </main>
</div> </div>
</body> </body>
<script src="{{ url_for('static', filename='index.js') }}"></script>
</html> </html>