mirror of
https://github.com/Fluffy-Bean/Fluffys-website.git
synced 2025-05-25 12:54:56 +00:00
Add darkmode
Prettier titles
This commit is contained in:
parent
b6077f88ed
commit
0ddc2a20b2
15 changed files with 187 additions and 76 deletions
31
static/js/title.js
Normal file
31
static/js/title.js
Normal file
|
@ -0,0 +1,31 @@
|
|||
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);
|
Loading…
Add table
Add a link
Reference in a new issue