Add terminal effect

This commit is contained in:
Tyler Perkins 2023-07-18 22:44:03 -04:00
parent b2f80c3a92
commit eb57cc04f4
6 changed files with 96 additions and 4 deletions

13
data/index.json Normal file
View File

@ -0,0 +1,13 @@
{
"Hobbies": [
{
"value": "Software Architecture"
},
{
"value": "Front End Development"
},
{
"value": "Back End Development"
}
]
}

View File

@ -4,4 +4,18 @@
{{ .Content }}
</div>
</div>
<div class="homepage-card">
<h1 to-show="about-description" data-value="uname -a" class="typewriter">~ $&nbsp;</h1>
<div class="about-grid">
<div id="about-description">
<p>Software developer with a passion for literally just about
everything.</p>
<p>Aspiring postmath; Jack of all trades, master of few.</p>
<p>Full stack developer at Etactics Inc.</p>
</div>
<div class="hobbies">
<p data-value="cat hobbies.txt | less" class="typewriter">~ $&nbsp;</p>
</div>
</div>
</div>
{{ end }}

View File

@ -1,13 +1,16 @@
.background {
background-image: url("/img/webb-dark.png");
position: absolute;
top: 0;
bottom: 0;
left: 0;
width: 100%;
height: 100%;
height: 150%;
overflow-y: hidden;
z-index: -1;
background-position: center;
background-repeat: repeat;
background-attachment: auto;
}

View File

@ -1,7 +1,7 @@
/* Footer */
footer {
background-color: rgba(11,11,11,0.9);
background-color: rgba(11,11,11,1);
color: white;
padding: 15px;
text-align: center;

View File

@ -9,6 +9,11 @@
font-display: swap;
}
@keyframes blink-caret {
from, to { border-color: transparent }
50% { border-color: white }
}
body {
overflow-x: hidden;
margin: 0;
@ -52,7 +57,7 @@ html {
}
.top-fade {
background: linear-gradient(rgba(11,11,12,1) 0%, rgba(11,11,12,0.9) 30%, rgba(0,0,0,0.1) 100%)
background: linear-gradient(rgba(11,11,12,1) 0%, rgba(11,11,12,0.9) 30%, rgba(0,0,0,0.0001) 100%)
}
.dashed-bottom {
@ -69,7 +74,35 @@ html {
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
.typewriter {
animation: blink-caret .75s step-end infinite;
border-right: .15em solid white;
display: inline;
}
.homepage-card {
height: calc(100vh - 6vh);
width: calc(100vw - 6vw);
padding: 1vh 1vw;
padding-top: 2vh;
background-color: rgba(11,11,12,0.4);
corner-radius: 10px;
margin: 2vh 2vw;
}
.about-grid {
display: grid;
grid-template-columns: 65% 1fr;
}
.hobbies {
background-color: black;
height: 100%;
padding: 10px;
}
.page-header {

View File

@ -1,4 +1,5 @@
const letters = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
const typeWriterSpeed = 60;
window.onload = function() {
document.querySelectorAll(".scramble").forEach(item => {
@ -11,6 +12,13 @@ window.onload = function() {
parallax.style.transform = 'translateY(' + scrollPosition * .5 + 'px)';
})
document.querySelectorAll(".typewriter").forEach(item => {
observer.observe(item);
});
}
function sleep(milliseconds) {
return new Promise(resolve => setTimeout(resolve, milliseconds));
}
function scramble(event){
@ -39,4 +47,25 @@ function scrambleLetters(element) {
}, 30);
}
async function typeWriter(element) {
let typeWriterText = element.getAttribute("data-value");
let output = element.innerText;
for(let i = 0; i < typeWriterText.length; ++i){
output += typeWriterText.charAt(i);
// sleep for typeWriterSpeed milliseconds
await sleep(typeWriterSpeed);
element.innerText = output;
}
}
let observer = new IntersectionObserver(function(entries) {
for (let entry of entries){
// If the element is visible, start the animation
if(entry.isIntersecting) {
typeWriter(entry.target);
observer.unobserve(entry.target);
}
}
}, { threshold: 0.7 });