mirror of
https://github.com/Fluffy-Bean/Fluffys-website.git
synced 2024-12-28 18:26:05 +00:00
32 lines
742 B
JavaScript
32 lines
742 B
JavaScript
const title = document.querySelector('h1');
|
|
const titleHeight = title.offsetHeight;
|
|
let titleText = title.textContent;
|
|
let letterOffset = 0;
|
|
let timeOffset = 10;
|
|
|
|
title.textContent = '';
|
|
title.style.height = titleHeight + 'px';
|
|
title.style.opacity = "1";
|
|
|
|
titleText.split('').forEach((letter) => {
|
|
let span = document.createElement('span');
|
|
|
|
span.textContent = letter;
|
|
span.style.left = letterOffset + 'px';
|
|
span.style.transform = 'translateY(100%)';
|
|
|
|
title.append(span);
|
|
|
|
setTimeout(() => {
|
|
span.style.transform = '';
|
|
}, timeOffset);
|
|
|
|
letterOffset += span.offsetWidth;
|
|
timeOffset += 100;
|
|
});
|
|
|
|
setTimeout(() => {
|
|
title.textContent = '';
|
|
title.textContent = titleText;
|
|
}, timeOffset + 500);
|