better caching, fixed cumulative layout shifts!
This commit is contained in:
parent
a37ca06241
commit
2339edcc39
2 changed files with 14 additions and 4 deletions
|
@ -4,11 +4,12 @@ const hamburger = document.getElementById("header-links-toggle");
|
|||
function type_out(e) {
|
||||
const text = e.innerText;
|
||||
const original = e.innerHTML;
|
||||
e.innerText = "";
|
||||
const delay = 25;
|
||||
let chars = 0;
|
||||
let html = "";
|
||||
|
||||
function insert_char(character, parent) {
|
||||
if (chars == 0) parent.innerHTML = "";
|
||||
const c = document.createElement("span");
|
||||
c.innerText = character;
|
||||
parent.appendChild(c);
|
||||
|
@ -20,7 +21,7 @@ function type_out(e) {
|
|||
}
|
||||
|
||||
function increment_char() {
|
||||
const newchar = text.substring(chars - 1, chars);
|
||||
const newchar = text.substring(chars, chars + 1);
|
||||
insert_char(newchar, e);
|
||||
chars++;
|
||||
if (chars <= text.length) {
|
||||
|
@ -63,4 +64,4 @@ document.addEventListener("click", event => {
|
|||
if (!header_links.contains(event.target) && !hamburger.contains(event.target)) {
|
||||
header_links.classList.remove("open");
|
||||
}
|
||||
});
|
||||
});
|
||||
|
|
Reference in a new issue